Restore the #theme_options feature for custom fields

Created on 22 December 2024, 3 days ago

Problem/Motivation

Label Help's README describes a way to add label help programmatically via custom code.

This was a holdover of something that worked in Drupal 7, but the code samples in the README do not actually work in the 8.x or 2.x branches of this module.

Steps to reproduce

1. Install Drupal 10.
2. Install Label Help.
3. Create a custom module with the following code:


/**
 * Implements hook_form_alter().
 */
function MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {
  // Add label_help to an existing field, like the Node Title field.
  if (isset($form['title'])) {
    $form['title']['#theme_options']['description at top'] = t('Label help message for the Title field.');
  }
}

4. Load /node/add/article page.

Proposed resolution

Instead of $element['#theme_options']['description at top'], support $element['#label_help'] to self-document the raison d'etre.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇪🇨Ecuador jwilson3

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