Commit bf534a21 authored by webchick's avatar webchick
Browse files

#992928 by das-peter, David_Rothstein: Fixed Command line (Drush) install...

#992928 by das-peter, David_Rothstein: Fixed Command line (Drush) install fails on SQLite (#limit_validation_errors doesn't work for programmatic form submissions)
parent 3999984b
...@@ -661,9 +661,14 @@ function drupal_form_submit($form_id, &$form_state) { ...@@ -661,9 +661,14 @@ function drupal_form_submit($form_id, &$form_state) {
// Merge in default values. // Merge in default values.
$form_state += form_state_defaults(); $form_state += form_state_defaults();
$form = drupal_retrieve_form($form_id, $form_state); // Populate $form_state['input'] with the submitted values before retrieving
// the form, to be consistent with what drupal_build_form() does for
// non-programmatic submissions (form builder functions may expect it to be
// there).
$form_state['input'] = $form_state['values']; $form_state['input'] = $form_state['values'];
$form_state['programmed'] = TRUE; $form_state['programmed'] = TRUE;
$form = drupal_retrieve_form($form_id, $form_state);
// Programmed forms are always submitted. // Programmed forms are always submitted.
$form_state['submitted'] = TRUE; $form_state['submitted'] = TRUE;
......
...@@ -1222,6 +1222,15 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase { ...@@ -1222,6 +1222,15 @@ class FormsProgrammaticTestCase extends DrupalWebTestCase {
$this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => 2)), TRUE); $this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => 2)), TRUE);
$this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => NULL)), TRUE); $this->submitForm(array('textfield' => 'dummy value', 'checkboxes' => array(1 => NULL, 2 => NULL)), TRUE);
// Test that a programmatic form submission can correctly click a button
// that limits validation errors based on user input. Since we do not
// submit any values for "textfield" here and the textfield is required, we
// only expect form validation to pass when validation is limited to a
// different field.
$this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'all'), FALSE);
$this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'textfield'), FALSE);
$this->submitForm(array('op' => 'Submit with limited validation', 'field_to_validate' => 'field_to_validate'), TRUE);
// Restore the current batch status. // Restore the current batch status.
$batch = $current_batch; $batch = $current_batch;
} }
......
...@@ -1377,6 +1377,7 @@ function form_test_programmatic_form($form, &$form_state) { ...@@ -1377,6 +1377,7 @@ function form_test_programmatic_form($form, &$form_state) {
'#title' => 'Textfield', '#title' => 'Textfield',
'#type' => 'textfield', '#type' => 'textfield',
); );
$form['checkboxes'] = array( $form['checkboxes'] = array(
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#options' => array( '#options' => array(
...@@ -1388,6 +1389,39 @@ function form_test_programmatic_form($form, &$form_state) { ...@@ -1388,6 +1389,39 @@ function form_test_programmatic_form($form, &$form_state) {
'#default_value' => array(1, 2), '#default_value' => array(1, 2),
); );
$form['field_to_validate'] = array(
'#type' => 'radios',
'#title' => 'Field to validate (in the case of limited validation)',
'#description' => 'If the form is submitted by clicking the "Submit with limited validation" button, then validation can be limited based on the value of this radio button.',
'#options' => array(
'all' => 'Validate all fields',
'textfield' => 'Validate the "Textfield" field',
'field_to_validate' => 'Validate the "Field to validate" field',
),
'#default_value' => 'all',
);
// The main submit button for the form.
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
// A secondary submit button that allows validation to be limited based on
// the value of the above radio selector.
$form['submit_limit_validation'] = array(
'#type' => 'submit',
'#value' => 'Submit with limited validation',
// Use the same submit handler for this button as for the form itself.
// (This must be set explicitly or otherwise the form API will ignore the
// #limit_validation_errors property.)
'#submit' => array('form_test_programmatic_form_submit'),
);
if (!empty($form_state['input']['field_to_validate']) && $form_state['input']['field_to_validate'] != 'all') {
$form['submit_limit_validation']['#limit_validation_errors'] = array(
array($form_state['input']['field_to_validate']),
);
}
return $form; return $form;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment