You are here

function form_test_validate_form_validate in Drupal 7

Form validation handler for form_test_validate_form().

File

modules/simpletest/tests/form_test.module, line 378
Helper module for the form API tests.

Code

function form_test_validate_form_validate(&$form, &$form_state) {
  if ($form_state['values']['name'] == 'validate') {

    // Alter the form element.
    $form['name']['#value'] = '#value changed by #validate';

    // Alter the submitted value in $form_state.
    form_set_value($form['name'], 'value changed by form_set_value() in #validate', $form_state);

    // Output the element's value from $form_state.
    drupal_set_message(t('@label value: @value', array(
      '@label' => $form['name']['#title'],
      '@value' => $form_state['values']['name'],
    )));

    // Trigger a form validation error to see our changes.
    form_set_error('');
  }
}