function form_test_validate_form

Form builder for testing drupal_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.
1 string reference to 'form_test_validate_form'
form_test_menu in modules/simpletest/tests/form_test.module
Implements hook_menu().

File

modules/simpletest/tests/form_test.module, line 320

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.