function form_test_validate_required_form
7.x form_test.module | form_test_validate_required_form($form, &$form_state) |
Form constructor to test the #required property.
1 call to form_test_validate_required_form()
- FormsTestCase::testRequiredCheckboxesRadio in drupal-7.x/
modules/ simpletest/ tests/ form.test - Tests validation for required checkbox, select, and radio elements.
1 string reference to 'form_test_validate_required_form'
- form_test_menu in drupal-7.x/
modules/ simpletest/ tests/ form_test.module - Implements hook_menu().
File
- drupal-7.x/
modules/ simpletest/ tests/ form_test.module, line 373 - Helper module for the form API tests.
Code
function form_test_validate_required_form($form, &$form_state) {
$options = drupal_map_assoc(array('foo', 'bar'));
$form['textfield'] = array(
'#type' => 'textfield',
'#title' => 'Textfield',
'#required' => TRUE,
);
$form['checkboxes'] = array(
'#type' => 'checkboxes',
'#title' => 'Checkboxes',
'#options' => $options,
'#required' => TRUE,
);
$form['select'] = array(
'#type' => 'select',
'#title' => 'Select',
'#options' => $options,
'#required' => TRUE,
);
$form['radios'] = array(
'#type' => 'radios',
'#title' => 'Radios',
'#options' => $options,
'#required' => TRUE,
);
$form['radios_optional'] = array(
'#type' => 'radios',
'#title' => 'Radios (optional)',
'#options' => $options,
);
$form['radios_optional_default_value_false'] = array(
'#type' => 'radios',
'#title' => 'Radios (optional, with a default value of FALSE)',
'#options' => $options,
'#default_value' => FALSE,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Submit');
return $form;
}