1 form_test.module form_test_validate_form($form, &$form_state)

Form builder for testing backdrop_validate_form().

Serves for testing form processing and alterations by form validation handlers, especially for the case of a validation error:

  • form_set_value() should be able to alter submitted values in $form_state['values'] without affecting the form element.
  • #element_validate handlers should be able to alter the $element in the form structure and the alterations should be contained in the rebuilt form.
  • #validate handlers should be able to alter the $form and the alterations should be contained in the rebuilt form.

File

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

Code

function form_test_validate_form($form, &$form_state) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Name',
    '#default_value' => '',
    '#element_validate' => array('form_test_element_validate_name'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save',
  );

  // To simplify this test, enable form caching and use form storage to
  // remember our alteration.
  $form_state['cache'] = TRUE;

  return $form;
}