1 form_test.module form_test_checkboxes_radios_defaults($form, &$form_state, $customize = FALSE)

Form constructor to test default options in checkboxes and radios.

File

core/modules/simpletest/tests/form_test.module, line 1769
Helper module for the Form API tests.

Code

function form_test_checkboxes_radios_defaults($form, &$form_state, $customize = FALSE) {
  $form['#submit'] = array('_form_test_submit_values_json');

  // Mix string and numeric keys and set a string default value.
  $form['checkboxes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Checkboxes'),
    '#options' => array(
      'foo' => t('Foo'),
      0 => t('Zero'),
      'bar' => t('Bar'),
    ),
    '#default_value' => array('foo'),
  );
  $form['radios'] = array(
    '#type' => 'radios',
    '#title' => t('Radios'),
    '#options' => array(
      'foo' => t('Foo'),
      0 => t('Zero'),
      'bar' => t('Bar'),
    ),
    '#default_value' => 'foo',
  );

  $form['submit'] = array('#type' => 'submit', '#value' => 'Submit');

  return $form;
}