diff --git a/includes/form.inc b/includes/form.inc index c2b3780ac57..16c49f265ed 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -622,7 +622,8 @@ function theme_select($element) { $select = ''; $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : ''; _form_set_class($element, array('form-select')); - return theme('form_element', $element['#title'], '', $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + $multiple = isset($element['#multiple']) && $element['#multiple']; + return theme('form_element', $element, ''); } function form_select_options($element, $choices = NULL) { @@ -674,7 +675,6 @@ function theme_fieldset($element) { } return '' . ($element['#title'] ? ''. $element['#title'] .'' : '') . ($element['#description'] ? '
'. $element['#description'] .'
' : '') . $element['#children'] . $element['#value'] . "\n"; - } /** @@ -696,7 +696,9 @@ function theme_radio($element) { if (!is_null($element['#title'])) { $output = ''; } - return theme('form_element', NULL, $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + + unset($element['#title']); + return theme('form_element', $element, $output); } /** @@ -710,7 +712,8 @@ function theme_radio($element) { */ function theme_radios($element) { if ($element['#title'] || $element['#description']) { - return theme('form_element', $element['#title'], $element['#children'], $element['#description'], NULL, $element['#required'], form_get_error($element)); + unset($element['#id']); + return theme('form_element', $element, $element['#children']); } else { return $element['#children']; @@ -727,7 +730,7 @@ function theme_radios($element) { * A themed HTML string representing the form item. */ function theme_password_confirm($element) { - return theme('form_element', $element['#title'], '
'. $element['#children']. '
', $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + return theme('form_element', $element, '
'. $element['#children'] .'
'); } /* @@ -776,8 +779,7 @@ function password_confirm_validate($form) { * A themed HTML string representing the date selection boxes. */ function theme_date($element) { - $output = '
' . $element['#children'] . '
'; - return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + return theme('form_element', $element, '
'. $element['#children'] .'
'); } /** @@ -883,7 +885,7 @@ function expand_radios($element) { * A themed HTML string representing the form item. */ function theme_item($element) { - return theme('form_element', $element['#title'], $element['#value'] . $element['#children'], $element['#description'], $element['#id'], $element['#required'], $element['#error']); + return theme('form_element', $element, $element['#value'] . $element['#children']); } /** @@ -909,7 +911,8 @@ function theme_checkbox($element) { $checkbox = ''; } - return theme('form_element', NULL, $checkbox, $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + unset($element['#title']); + return theme('form_element', $element, $checkbox); } /** @@ -922,7 +925,8 @@ function theme_checkbox($element) { */ function theme_checkboxes($element) { if ($element['#title'] || $element['#description']) { - return theme('form_element', $element['#title'], $element['#children'], $element['#description'], NULL, $element['#required'], form_get_error($element)); + unset($element['#id']); + return theme('form_element', $element, $element['#children']); } else { return $element['#children']; @@ -994,7 +998,7 @@ function theme_textfield($element) { } _form_set_class($element, $class); $output = ''; - return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element)). $extra; + return theme('form_element', $element, $output). $extra; } /** @@ -1030,7 +1034,7 @@ function theme_textarea($element) { $cols = $element['#cols'] ? ' cols="'. $element['#cols'] .'"' : ''; _form_set_class($element, $class); - return theme('form_element', $element['#title'], ''. check_plain($element['#value']) .'', $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + return theme('form_element', $element, ''. check_plain($element['#value']) .''); } /** @@ -1040,7 +1044,7 @@ function theme_textarea($element) { * * @param $element * An associative array containing the properties of the element. - * Properties used: prefix, value, children and suffix. + * Properties used: value, children. * @return * A themed HTML string representing the HTML markup. */ @@ -1063,8 +1067,7 @@ function theme_password($element) { _form_set_class($element, array('form-text')); $output = ''; - - return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + return theme('form_element', $element, $output); } /** @@ -1107,7 +1110,43 @@ function theme_weight($element) { */ function theme_file($element) { _form_set_class($element, array('form-file')); - return theme('form_element', $element['#title'], '\n", $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); + return theme('form_element', $element, '\n"); +} + +/** + * Return a themed form element. + * + * @param element + * An associative array containing the properties of the element. + * Properties used: title, description, id, required + * @param $value + * the form element's data + * @return + * a string representing the form element + */ +function theme_form_element($element, $value) { + $output = '
'."\n"; + $required = !empty($element['#required']) ? '*' : ''; + + if (!empty($element['#title'])) { + $title = $element['#title']; + if (!empty($element['#id'])) { + $output .= ' \n"; + } + else { + $output .= ' \n"; + } + } + + $output .= " $value\n"; + + if (!empty($element['#description'])) { + $output .= '
'. $element['#description'] ."
\n"; + } + + $output .= "
\n"; + + return $output; } /** diff --git a/includes/theme.inc b/includes/theme.inc index 3d933194e09..91996d2b8bc 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -606,43 +606,6 @@ function theme_node($node, $teaser = FALSE, $page = FALSE) { return $output; } -/** - * Return a themed form element. - * - * @param $title the form element's title - * @param $value the form element's data - * @param $description the form element's description or explanation - * @param $id the form element's ID used by the <label> tag - * @param $required a boolean to indicate whether this is a required field or not - * @param $error a string with an error message filed against this form element - * - * @return a string representing the form element - */ -function theme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) { - - $output = '
'."\n"; - $required = $required ? '*' : ''; - - if ($title) { - if ($id) { - $output .= ' \n"; - } - else { - $output .= ' \n"; - } - } - - $output .= " $value\n"; - - if ($description) { - $output .= '
'. $description ."
\n"; - } - - $output .= "
\n"; - - return $output; -} - /** * Return a themed submenu, typically displayed under the tabs. *