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