1 form.inc | theme_form_element_description(array $variables) |
Returns HTML for a form element's help text (#description).
Form element descriptions may appear before or after elements, depending on theme_form_element() and #description_display.
This function will not be called for elements with no description.
@since 1.30.0 Function added.
Parameters
array $variables: An associative array containing:
- element: An associative array containing the properties of the element.
Related topics
File
- core/
includes/ form.inc, line 5099 - Functions for form and batch generation and processing.
Code
function theme_form_element_description(array $variables) {
$element = $variables['element'];
// This is also used in the installer, pre-database setup.
$t = get_t();
// If description is not set, output nothing.
if (!isset($element['#description'])) {
return '';
}
$attributes = array('class' => array('description'));
if (isset($element['#description_display']) && $element['#description_display'] === 'invisible') {
$attributes['class'][] = 'element-invisible';
}
return '<div' . backdrop_attributes($attributes) . '>' . $element['#description'] . "</div>\n";
}