function variable_realm_select_variables_form in Variable 7
Same name and namespace in other branches
- 7.2 variable_realm/variable_realm.form.inc \variable_realm_select_variables_form()
Select variables for realm.
1 string reference to 'variable_realm_select_variables_form'
- variable_realm_admin_menu in variable_realm_admin/
variable_realm_admin.module - Implements hook_menu().
File
- variable_realm/
variable_realm.form.inc, line 10 - Administrative forms for variable realms.
Code
function variable_realm_select_variables_form($form, &$form_state, $realm_name) {
$current = variable_realm_get_variable_list($realm_name);
$optional = variable_realm_get_variable_options($realm_name);
// The final list will be the sum of both lists. We may have unknown variables
// we want to preserve.
$list = array_unique(array_merge($optional, $current));
$form['realm_name'] = array(
'#type' => 'value',
'#value' => $realm_name,
);
$form['variables'] = array(
'#type' => 'fieldset',
'#title' => t('Select variables to be set for this realm'),
'#theme' => 'variable_table_select',
'#tree' => TRUE,
);
foreach ($list as $name) {
// Variable names may clash with form element names, so we need to replace '[' and ']'
$safename = str_replace(array(
'[',
']',
), array(
'<',
'>',
), $name);
$form['variables'][$safename] = array(
'#type' => 'checkbox',
'#default_value' => in_array($name, $current),
'#variable_name' => $name,
);
}
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}