function form_test_limit_validation_errors_form
Builds a simple form with a button triggering partial validation.
1 string reference to 'form_test_limit_validation_errors_form'
- form_test_menu in modules/
simpletest/ tests/ form_test.module - Implements hook_menu().
File
-
modules/
simpletest/ tests/ form_test.module, line 488
Code
function form_test_limit_validation_errors_form($form, &$form_state) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => 'Title',
'#required' => TRUE,
);
$form['test'] = array(
'#title' => 'Test',
'#type' => 'textfield',
'#element_validate' => array(
'form_test_limit_validation_errors_element_validate_test',
),
);
$form['test_numeric_index'] = array(
'#tree' => TRUE,
);
$form['test_numeric_index'][0] = array(
'#title' => 'Test (numeric index)',
'#type' => 'textfield',
'#element_validate' => array(
'form_test_limit_validation_errors_element_validate_test',
),
);
$form['test_substring'] = array(
'#tree' => TRUE,
);
$form['test_substring']['foo'] = array(
'#title' => 'Test (substring) foo',
'#type' => 'textfield',
'#element_validate' => array(
'form_test_limit_validation_errors_element_validate_test',
),
);
$form['test_substring']['foobar'] = array(
'#title' => 'Test (substring) foobar',
'#type' => 'textfield',
'#element_validate' => array(
'form_test_limit_validation_errors_element_validate_test',
),
);
$form['actions']['partial'] = array(
'#type' => 'submit',
'#limit_validation_errors' => array(
array(
'test',
),
),
'#submit' => array(
'form_test_limit_validation_errors_form_partial_submit',
),
'#value' => t('Partial validate'),
);
$form['actions']['partial_numeric_index'] = array(
'#type' => 'submit',
'#limit_validation_errors' => array(
array(
'test_numeric_index',
0,
),
),
'#submit' => array(
'form_test_limit_validation_errors_form_partial_submit',
),
'#value' => t('Partial validate (numeric index)'),
);
$form['actions']['substring'] = array(
'#type' => 'submit',
'#limit_validation_errors' => array(
array(
'test_substring',
'foo',
),
),
'#submit' => array(
'form_test_limit_validation_errors_form_partial_submit',
),
'#value' => t('Partial validate (substring)'),
);
$form['actions']['full'] = array(
'#type' => 'submit',
'#value' => t('Full validate'),
);
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.