1 form_test.module | form_test_checkboxes_radios($form, &$form_state, $customize = FALSE) |
Form constructor to test expansion of #type checkboxes and radios.
File
- core/
modules/ simpletest/ tests/ form_test.module, line 1560 - Helper module for the Form API tests.
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;
}