Skip to main content

Alter field title of content type to display description below the field title

Submitted by system on
This can be achieved using hook_node_view <?php function ji_custom_node_view($node, $view_mode, $langcode) { if($view_mode != 'full'){ return; } switch ($node->type) { case 'blood_donor_form': foreach ($node->content as $field_name => $field_options) { if(isset($field_options['#title']) && isset($field_options[0]['markup'])) { $node->content["$field_name"]['#title'] = $field_options['#title'] ."".$field_options[0]['markup']['#suffix'].""; unset($node->content["$field_name"][0]['markup']['#suffix']); } } break; } } ?> The code alters each field attaching the description just after the label of the field, if present. Also prefixes with a div class for custom css option for the description fields. -- Similar modules https://www.drupal.org/project/label_help