You are here

function variable_form_element_options in Variable 7

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

Build options variables

2 calls to variable_form_element_options()
locale_variable_language_default_element in includes/locale.variable.inc
Form element for site default language
variable_form_element in ./variable.form.inc
Build form element for a variable
1 string reference to 'variable_form_element_options'
variable_variable_type_info in ./variable.variable.inc
Implements hook_variable_type_info().

File

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

Code

function variable_form_element_options($variable, $options = array()) {
  $element = variable_form_element_default($variable, $options);
  $element['#options'] = $variable['options'];

  // Depending on the number of options this may be radios or a drop-down.
  // However if there are nested options (an option is an array) it should be always a drop-down.
  if (empty($element['#type'])) {
    $element['#type'] = count($variable['options']) > 4 || array_filter(array_map('is_array', $variable['options'])) ? 'select' : 'radios';
  }
  return $element;
}