function form_test_checkboxes_radios
Form constructor to test expansion of #type checkboxes and radios.
1 string reference to 'form_test_checkboxes_radios'
- form_test_menu in modules/
simpletest/ tests/ form_test.module - Implements hook_menu().
File
-
modules/
simpletest/ tests/ form_test.module, line 1305
Code
function form_test_checkboxes_radios($form, &$form_state, $customize = FALSE) {
$form['#submit'] = array(
'_form_test_submit_values_json',
);
// Expand #type checkboxes, setting custom element properties for some but not
// all options.
$form['checkboxes'] = array(
'#type' => 'checkboxes',
'#title' => 'Checkboxes',
'#options' => array(
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar',
'>' => 'Special Char',
),
);
if ($customize) {
$form['checkboxes'] += array(
'foo' => array(
'#description' => 'Enable to foo.',
),
1 => array(
'#weight' => 10,
),
);
}
// Expand #type radios, setting custom element properties for some but not
// all options.
$form['radios'] = array(
'#type' => 'radios',
'#title' => 'Radios',
'#options' => array(
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar',
'>' => 'Special Char',
),
);
if ($customize) {
$form['radios'] += array(
'foo' => array(
'#description' => 'Enable to foo.',
),
1 => array(
'#weight' => 10,
),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.