function theme_form_element in Drupal 4
Same name and namespace in other branches
- 5 includes/form.inc \theme_form_element()
- 6 includes/form.inc \theme_form_element()
- 7 includes/form.inc \theme_form_element()
Return a themed form element.
Parameters
$title the form element's title:
$value the form element's data:
$description the form element's description or explanation:
$id the form element's ID used by the <label> tag:
$required a boolean to indicate whether this is a required field or not:
$error a string with an error message filed against this form element:
Return value
a string representing the form element
Related topics
12 theme calls to theme_form_element()
- theme_checkbox in includes/
form.inc - Format a checkbox.
- theme_checkboxes in includes/
form.inc - Format a set of checkboxes.
- theme_date in includes/
form.inc - Format a date selection element.
- theme_file in includes/
form.inc - Format a file upload field.
- theme_item in includes/
form.inc - Format a form item.
File
- includes/
theme.inc, line 621 - The theme system, which controls the output of Drupal.
Code
function theme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {
$output = '<div class="form-item">' . "\n";
$required = $required ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
if ($title) {
if ($id) {
$output .= ' <label for="' . form_clean_id($id) . '">' . t('%title: %required', array(
'%title' => filter_xss_admin($title),
'%required' => $required,
)) . "</label>\n";
}
else {
$output .= ' <label>' . t('%title: %required', array(
'%title' => filter_xss_admin($title),
'%required' => $required,
)) . "</label>\n";
}
}
$output .= " {$value}\n";
if ($description) {
$output .= ' <div class="description">' . $description . "</div>\n";
}
$output .= "</div>\n";
return $output;
}