Currently label help text is shown on edit form, but we do also want them to shown on View mode, is there any easy way to do so?
thanks for any help in advance.

Comments

bluemoonj created an issue.

astonvictor’s picture

There is no possibility to do that with Label Help.
You can implement hook_entity_view() in your custom module.

works for me:

/**
 * Implements hook_entity_view().
 */
function MODULE_entity_view($entity, $type, $view_mode, $langcode) {
  $field_name = 'body';
  $ids = entity_extract_ids($type, $entity);
  $field = field_info_instance($type, $field_name, $ids[2]);

  if (isset($field['widget']['settings']['label_help_description'])) {
    $tag = array(
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#attributes' => array('class' => 'label-help'),
      '#value' =>  $field['widget']['settings']['label_help_description'],
    );

    $entity->content[$field_name]['#prefix'] = render($tag);
  }
}