form_pre_render_conditional_form_element

7 form.inc form_pre_render_conditional_form_element($element)
8 form.inc form_pre_render_conditional_form_element($element)

Adds form element theming to an element if its title or description is set.

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

Related topics

1 string reference to 'form_pre_render_conditional_form_element'

File

includes/form.inc, line 3087
Functions for form and batch generation and processing.

Code

function form_pre_render_conditional_form_element($element) {
  $t = get_t();
  // 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'])) {
    $element['#theme_wrappers'][] = 'form_element';
  }
  return $element;
}

Comments

What is $t() here? Is it a

What is $t() here? Is it a bug?

get_t() exists to support

get_t() exists to support localization for code that might run during the installation phase, when some elements of the system might not have loaded.

This ensures translations work during install.

Login or register to post comments