function theme_fel_form_element in Form element layout 7
Replacement theme for 'form_element'.
See also
File
- ./
fel.module, line 160 - Reorder #title, #description and #children in forms.
Code
function theme_fel_form_element($variables) {
$element =& $variables['element'];
// This function is invoked as theme wrapper, but the rendered form element
// may not necessarily have been processed by form_builder().
$element += array(
'#title_display' => 'before',
);
// Add element #id for #type 'item'.
if (isset($element['#markup']) && !empty($element['#id'])) {
$attributes['id'] = $element['#id'];
}
// Add element's #type and #name as class to aid with JS/CSS selectors.
$attributes['class'] = array(
'form-item',
);
if (!empty($element['#type'])) {
$attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-');
}
if (!empty($element['#name'])) {
$replacements = array(
' ' => '-',
'_' => '-',
'[' => '-',
']' => '',
);
$attributes['class'][] = 'form-item-' . strtr($element['#name'], $replacements);
}
// Add a class for disabled elements to facilitate cross-browser styling.
if (!empty($element['#attributes']['disabled'])) {
$attributes['class'][] = 'form-disabled';
}
$output = '<div' . drupal_attributes($attributes) . '>' . "\n";
// If #title is not set, we don't display any label or required marker.
if (!isset($element['#title'])) {
$element['#title_display'] = 'none';
}
$prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : '';
$suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : '';
$element_parts = array(
'children' => $prefix . $element['#children'] . $suffix,
);
if ($element['#title_display'] != 'none' and $element['#title_display'] != 'attribute') {
$element_parts['title'] = theme('fel_form_element_label', $variables);
}
if (!empty($element['#description'])) {
$element_parts['description'] = theme('fel_form_element_description', $variables) . "\n";
}
fel_order_output($element, $element_parts);
$output .= implode(' ', $element_parts);
$output .= "\n</div>\n";
return $output;
}