Convert "tips" to an "item_list"

Created on 24 July 2025, 19 days ago

Problem/Motivation

The "tips" section displays important information to the site maintainer when editing the text format.

Currently, it is a single text string, containing a HTML unordered list, passed through the translation interface. This has several disadvantages:

  • The use of HTML in translated strings is discouraged, and should generally be limited to simple bold/italic style tags.
  • A single string for all the list items means that any time one item in the list changes, the whole translation needs updating.
  • Any change to the list will cause the whole list to be untranslated until translations are updated.

In 📌 Remove/lesson dependency on "Convert line breaks into HTML" Active I set the tips to use the item_list theme to format a list from an array of translated strings. However, as there are many issues tweaking the tips, I think it would be better to move it into a dedicated issue.

Proposed resolution

Drupal core provide the item_list theme function to convert an array into a HTML list as follows:

    $form['tips'] = [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#title' => $this->t('Important'),
      '#items' => [
        $this->t(''),
      ],
      '#attributes' => ['class' => 'form-item__description'],
    ];

This means that each item is a separate translated string, which makes the module more translatable, avoids HTML in the translation strings, and allows each tip to be considered as a separate translation item.

Remaining tasks

First we should discuss the appropriate time to implement this. It may be better to implement on the current list of tips in the 2.0 branch, and refactor into other issues awaiting merge. Or it may be better to merge RTBC issues first and convert the final list. We should try to get this implemented and merged fairly quickly, otherwise it is likely to need rebasing every time an issue that changes any tips gets merged.

We should also check that we do some checking of the tips in test cases, to ensure the before and after remains broadly the same, and ensure any new tests pass on the current implementation.

Finally we should replace the current tips with the structure above, and ensure the tests still pass.

User interface changes

There should be no obvious difference for the end user.

API changes

None.

Data model changes

None.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024