form_pre_render_conditional_form_element

Versions
7
form_pre_render_conditional_form_element($element)

Add form_element theming to an element if title or description is set.

This is used as a pre render function for checkboxes and radios.

Related topics

Code

includes/form.inc, line 2227

<?php
function form_pre_render_conditional_form_element($element) {
  // Set the element's title attribute to show #title as a tooltip, if needed.
  if (isset($element['#title']) && $element['#title_display'] == 'attribute') {
    $element['#attributes']['title'] = $element['#title'];
    if (!empty($element['#required'])) {
      // Append an indication that this field is required.
      $element['#attributes']['title'] .= ' (' . $t('Required') . ')';
    }
  }

  if (isset($element['#title']) || isset($element['#description'])) {
    unset($element['#id']);
    $element['#theme_wrappers'][] = 'form_element';
  }
  return $element;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.