diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index 9f84689..134dbcd 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -104,8 +104,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { array('driver'), array($default_driver), ), - '#submit' => array('::submitForm'), - '#suppress_form_level_submit' => TRUE, + // This must be present to allow #limit_validation_errors to function. The + // form-level ::submitForm() handler will fire accordingly. + '#submit' => [], ); $form['errors'] = array(); diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index b8101c6..cad6860 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -250,8 +250,7 @@ protected function actions(array $form, FormStateInterface $form_state) { '#value' => $this->t('Preview'), '#access' => $preview_mode != DRUPAL_DISABLED, '#validate' => array('::validate'), - '#submit' => array('::submitForm', '::preview'), - '#suppress_form_level_submit' => TRUE, + '#submit' => ['::preview'], ); return $element; diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 7026863..774de46 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -156,10 +156,10 @@ public function actions(array $form, FormStateInterface $form_state) { $elements = parent::actions($form, $form_state); $elements['submit']['#value'] = $this->t('Send message'); $elements['preview'] = array( + '#type' => 'submit', '#value' => $this->t('Preview'), '#validate' => array('::validate'), - '#submit' => array('::submitForm', '::preview'), - '#suppress_form_level_submit' => TRUE, + '#submit' => array('::preview'), ); return $elements; } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 5c2e22f..f987007 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -107,6 +107,7 @@ function field_ui_form_node_type_form_alter(&$form, FormStateInterface $form_sta $form['actions']['save_continue']['#value'] = t('Save and manage fields'); $form['actions']['save_continue']['#weight'] = $form['actions']['save_continue']['#weight'] + 5; $form['actions']['save_continue']['#submit'][] = 'field_ui_form_node_type_form_submit'; + $form['actions']['save_continue']['#suppress_form_level_submit'] = TRUE; // Hide the 'Save content type' button. $form['actions']['submit']['#access'] = FALSE; } diff --git a/core/modules/field_ui/src/Form/FieldEditForm.php b/core/modules/field_ui/src/Form/FieldEditForm.php index 9abf3d5..08e673d 100644 --- a/core/modules/field_ui/src/Form/FieldEditForm.php +++ b/core/modules/field_ui/src/Form/FieldEditForm.php @@ -168,6 +168,7 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldConf '#type' => 'submit', '#value' => $this->t('Delete field'), '#submit' => array('::delete'), + '#suppress_form_level_submit' => TRUE, ); return $form; } diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 1ad5a1f..9f4f2e9 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -413,6 +413,7 @@ public static function process($element, FormStateInterface $form_state, $form) // not just the individual item, to be valid. foreach (array('upload_button', 'remove_button') as $key) { $element[$key]['#submit'][] = array(get_called_class(), 'submit'); + $element[$key]['#suppress_form_level_submit'] = TRUE; $element[$key]['#limit_validation_errors'] = array(array_slice($element['#parents'], 0, -1)); } diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php index 24f5142..dae7fb5 100644 --- a/core/modules/forum/src/Form/Overview.php +++ b/core/modules/forum/src/Form/Overview.php @@ -86,9 +86,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Remove the alphabetical reset. unset($form['actions']['reset_alphabetical']); - // The form needs to have submit and validate handlers set explicitly. // Use the existing taxonomy overview submit handler. - $form['#submit'] = array('::submitForm'); $form['terms']['#empty'] = $this->t('No containers or forums available. Add container or Add forum.', array( '@container' => $this->url('forum.add_container'), '@forum' => $this->url('forum.add_forum') diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index becc1db..12a7fe4 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -173,8 +173,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Add'), '#validate' => array('::effectValidate'), - '#submit' => array('::submitForm', '::effectSave'), - '#suppress_form_level_submit' => TRUE, + '#submit' => ['::effectSave'], ), ), ), diff --git a/core/modules/language/src/Form/LanguageAddForm.php b/core/modules/language/src/Form/LanguageAddForm.php index f0b1029..a719828 100644 --- a/core/modules/language/src/Form/LanguageAddForm.php +++ b/core/modules/language/src/Form/LanguageAddForm.php @@ -53,7 +53,7 @@ public function form(array $form, FormStateInterface $form_state) { ), ), '#validate' => array('::validatePredefined'), - '#submit' => array('::submitForm', '::save'), + '#submit' => array('::save'), ); $custom_language_states_conditions = array( @@ -76,7 +76,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Add custom language'), '#validate' => array('::validateCustom'), - '#submit' => array('::submitForm', '::save'), + '#submit' => array('::save'), ); return $form; diff --git a/core/modules/language/src/Form/LanguageEditForm.php b/core/modules/language/src/Form/LanguageEditForm.php index 79a3a17..6669860 100644 --- a/core/modules/language/src/Form/LanguageEditForm.php +++ b/core/modules/language/src/Form/LanguageEditForm.php @@ -39,7 +39,7 @@ public function actions(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Save language'), '#validate' => array('::validateCommon'), - '#submit' => array('::submitForm', '::save'), + '#submit' => ['::save'], ); return $actions; } diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 44fccbf..473120d 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -274,7 +274,7 @@ protected function actions(array $form, FormStateInterface $form_state) { '#value' => t('Preview'), '#weight' => 20, '#validate' => array('::validate'), - '#submit' => array('::submitForm', '::preview'), + '#submit' => ['::preview'], ); $element['delete']['#access'] = $node->access('delete'); diff --git a/core/modules/shortcut/src/Form/SetCustomize.php b/core/modules/shortcut/src/Form/SetCustomize.php index 4f84888..9bb3b5b 100644 --- a/core/modules/shortcut/src/Form/SetCustomize.php +++ b/core/modules/shortcut/src/Form/SetCustomize.php @@ -97,7 +97,7 @@ protected function actions(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => t('Save changes'), '#access' => (bool) Element::getVisibleChildren($form['shortcuts']['links']), - '#submit' => array('::submitForm', '::save'), + '#submit' => ['::save'], ), ); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php index 4a142cb..4976541 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php @@ -71,11 +71,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { $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('::submitForm'), - '#suppress_form_level_submit' => TRUE, + // This must be present to allow #limit_validation_errors to function. The + // form-level ::submitForm() handler will fire accordingly. + '#submit' => [], ); $user_input = $form_state->getUserInput(); if (!empty($user_input['field_to_validate']) && $user_input['field_to_validate'] != 'all') { diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php index e34d4a1..91838b8 100644 --- a/core/modules/views/src/Plugin/views/field/Field.php +++ b/core/modules/views/src/Plugin/views/field/Field.php @@ -467,6 +467,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { 'url' => views_ui_build_form_url($form_state), ), '#submit' => array(array($this, 'submitTemporaryForm')), + '#suppress_form_level_submit' => TRUE, '#executes_submit_callback' => TRUE, ); diff --git a/core/modules/views_ui/src/ViewAddForm.php b/core/modules/views_ui/src/ViewAddForm.php index 9f28cfe..6d292c5 100644 --- a/core/modules/views_ui/src/ViewAddForm.php +++ b/core/modules/views_ui/src/ViewAddForm.php @@ -147,9 +147,12 @@ public function form(array $form, FormStateInterface $form_state) { */ protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); - $actions['submit']['#value'] = $this->t('Save and edit'); - // Remove EntityFormController::save() form the submission handlers. - $actions['submit']['#submit'] = array(array($this, 'submitForm')); + // Overwrite the submit button to prevent ::save() from being called. + $actions['submit'] = array( + '#type' => 'submit', + '#value' => $this->t('Save and edit'), + '#validate' => array('::validate'), + ); $actions['cancel'] = array( '#type' => 'submit', '#value' => $this->t('Cancel'),