You are here

function theme_form_element in Drupal 6

Same name and namespace in other branches
  1. 4 includes/theme.inc \theme_form_element()
  2. 5 includes/form.inc \theme_form_element()
  3. 7 includes/form.inc \theme_form_element()

Return a themed form element.

Parameters

element: An associative array containing the properties of the element. Properties used: title, description, id, required

$value: The form element's data.

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.

... See full list

File

includes/form.inc, line 2322

Code

function theme_form_element($element, $value) {

  // This is also used in the installer, pre-database setup.
  $t = get_t();
  $output = '<div class="form-item"';
  if (!empty($element['#id'])) {
    $output .= ' id="' . $element['#id'] . '-wrapper"';
  }
  $output .= ">\n";
  $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : '';
  if (!empty($element['#title'])) {
    $title = $element['#title'];
    if (!empty($element['#id'])) {
      $output .= ' <label for="' . $element['#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 (!empty($element['#description'])) {
    $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
  }
  $output .= "</div>\n";
  return $output;
}