Problem/Motivation

The help text of the form element is not displayed. Especially for IEF they are pretty important IMHO.

Steps to reporoduce

  • Add help text to an entity reference field with IEF widget.
  • The help text will not show up, for other widgets it is working fine.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

axe312 created an issue. See original summary.

axe312’s picture

This hook solves the issue in our project for now. It is not my code but I think it will help solving this issue and might also help other community members as workaround :)

Do not forget to replace YOUR_MODULE and YOUR_NODE_TYPE.

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function YOUR_MODULE_form_node_form_alter(&$form, &$form_state, $form_id) {
  $field_definitions = Drupal::entityManager()->getFieldDefinitions('node', 'YOUR_NODE_TYPE');
  foreach ($field_definitions as $fieldname => $field) {
    if ($field->getType() == 'entity_reference') {
      // @todo: This is the brute force attempt to fix missing descriptions on IEF widgets.
      $description = $field->getDescription();
      if (!empty($description) && !isset($form[$fieldname]['widget']['#description'])) {
        $form[$fieldname]['widget']['#description'] = $description;
      }
    }
  }
}

Edit: Sorry, really got no time this week to create a patch :)

yannickoo’s picture

I can help you mate :)

slashrsm’s picture

Status: Needs review » Needs work
Issue tags: +Media Initiative, +D8Media, +Needs tests

Patch looks ok, but we need test coverage.

Shreya Shetty’s picture

Previous patch was not compatible with the current code . Made changes so that it is applicable with the current version

Status: Needs review » Needs work

The last submitted patch, 5: inline_entity_form-show-field-description-2613324-5.patch, failed testing.

Shreya Shetty’s picture

Status: Needs work » Needs review
FileSize
1.27 KB
leahtard’s picture

Thanks for the patch! Fixed it for me.

Cheers, Leah

yannickoo’s picture

Status: Needs review » Needs work

So there is not test anymore in #7? I guess we need to make sure a test is included so setting back to Needs work.

kaythay’s picture

Status: Needs work » Closed (duplicate)