You are here

function theme_variable_table_select in Variable 7

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

Form to select variables

1 theme call to theme_variable_table_select()
variable_realm_select_variables_form in variable_realm/variable_realm.form.inc
Select variables for realm.

File

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

Code

function theme_variable_table_select($variables) {
  $element = $variables['element'];
  $header = isset($element['#header']) ? $element['#header'] : array(
    'element' => '',
    'title' => t('Name'),
    'description' => t('Description'),
  );
  $fields = array_keys($header);
  $rows = array();
  foreach (element_children($element) as $name) {
    $variable_name = isset($element[$name]['#variable_name']) ? $element[$name]['#variable_name'] : $name;
    $variable = _variable_variable($variable_name);
    $row = array();
    foreach ($fields as $field) {
      if ($field == 'element') {
        $row[] = drupal_render($element[$name]);
      }
      else {
        $row[] = isset($variable[$field]) ? $variable[$field] : '';
      }
    }
    $rows[] = $row;
  }

  // Add a "Select all" checkbox.
  drupal_add_js('misc/tableselect.js');
  $header['element'] = array(
    'class' => array(
      'select-all',
    ),
  );
  return theme('table', array(
    'header' => array_values($header),
    'rows' => $rows,
  ));
}