You are here

function variable_form_element_default in Variable 7

Same name and namespace in other branches
  1. 6 variable.form.inc \variable_form_element_default()
  2. 7.2 variable.form.inc \variable_form_element_default()

Build default form element

4 calls to variable_form_element_default()
system_variable_path_element in includes/system.variable.inc
Callback for path variable element
variable_form_element in ./variable.form.inc
Build form element for a variable
variable_form_element_array in ./variable.form.inc
Build array form element
variable_form_element_options in ./variable.form.inc
Build options variables

File

./variable.form.inc, line 88
Variable API module. Form library.

Code

function variable_form_element_default($variable, $options = array()) {
  $variable += array(
    'element' => array(),
    'title' => '',
    'description' => '',
  );
  $type = variable_get_type($variable['type']) + array(
    'element' => array(),
  );
  $element = $variable['element'] + array(
    '#title' => $variable['title'],
    '#description' => $variable['description'],
  ) + $type['element'];
  $value = variable_get_value($variable, $options);
  if (isset($value)) {
    $element['#default_value'] = $value;
  }
  return $element;
}