diff --git a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php index 887fcae..d61f0f4 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php @@ -89,9 +89,6 @@ protected function actions(array $form, FormStateInterface $form_state) { '#validate' => array( array($this, 'validate'), ), - '#submit' => array( - array($this, 'submitForm'), - ), ), 'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()), ); diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php index a11e27f..05e8465 100644 --- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -84,9 +84,6 @@ protected function actions(array $form, FormStateInterface $form_state) { '#validate' => array( array($this, 'validate'), ), - '#submit' => array( - array($this, 'submitForm'), - ), ), 'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()), ); diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index d3b127d..2d7643d 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -220,7 +220,7 @@ protected function actions(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Save'), '#validate' => array('::validate'), - '#submit' => array('::submitForm', '::save'), + '#submit' => ['::save'], ); if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('delete-form')) { diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index ef64fea..62b4963 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -228,6 +228,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f '#attributes' => array('class' => array('field-add-more-submit')), '#limit_validation_errors' => array(array_merge($parents, array($field_name))), '#submit' => array(array(get_class($this), 'addMoreSubmit')), + '#suppress_form_level_submit' => TRUE, '#ajax' => array( 'callback' => array(get_class($this), 'addMoreAjax'), 'wrapper' => $wrapper_id, diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index 8cf65c9..9f84689 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -105,6 +105,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { array($default_driver), ), '#submit' => array('::submitForm'), + '#suppress_form_level_submit' => TRUE, ); $form['errors'] = array(); diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 54efba4..e8eb2eb 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -155,6 +155,7 @@ function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form '#type' => 'submit', '#value' => t('Change book (update list of parents)'), '#submit' => array('book_pick_book_nojs_submit'), + '#suppress_form_level_submit' => TRUE, '#weight' => 20, '#attributes' => array( 'class' => array( diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index 8f7368a..cad6860 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -250,7 +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'), + '#submit' => ['::preview'], ); return $element; diff --git a/core/modules/config/tests/config_test/src/ConfigTestForm.php b/core/modules/config/tests/config_test/src/ConfigTestForm.php index 56195e2..084a009 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestForm.php +++ b/core/modules/config/tests/config_test/src/ConfigTestForm.php @@ -85,6 +85,7 @@ public function form(array $form, FormStateInterface $form_state) { 'class' => array('js-hide'), ), '#submit' => array(array(get_class($this), 'changeSize')), + '#suppress_form_level_submit' => TRUE, ); $form['size_wrapper']['size_value'] = array( '#type' => 'select', diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 110a6e4..ae414da 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -185,6 +185,7 @@ function contact_form_user_form_alter(&$form, FormStateInterface $form_state) { '#description' => t('Allow other users to contact you via a personal contact form which keeps your email address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.'), ); $form['actions']['submit']['#submit'][] = 'contact_user_profile_form_submit'; + $form['actions']['submit']['#suppress_form_level_submit'] = TRUE; } /** diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 908ed17..508540b 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -158,7 +158,7 @@ public function actions(array $form, FormStateInterface $form_state) { $elements['preview'] = array( '#value' => $this->t('Preview'), '#validate' => array('::validate'), - '#submit' => array('::submitForm', '::preview'), + '#submit' => ['::preview'], ); return $elements; } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 93d73f9..b87ed58 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -435,6 +435,7 @@ function content_translation_language_configuration_element_process(array $eleme $submit_name = isset($form['actions']['save_continue']) ? 'save_continue' : 'submit'; $form['actions'][$submit_name]['#submit'][] = 'content_translation_language_configuration_element_submit'; + $form['actions'][$submit_name]['#suppress_form_level_submit'] = TRUE; } return $element; } diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index eab020f..1cfac81 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -272,6 +272,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En '#type' => 'submit', '#value' => t('Change'), '#submit' => array(array($this, 'entityFormSourceChange')), + '#suppress_form_level_submit' => TRUE, ), ); foreach ($this->languageManager->getLanguages() as $language) { @@ -324,6 +325,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En '#value' => t('Delete translation'), '#weight' => $weight, '#submit' => array(array($this, 'entityFormDeleteTranslation')), + '#suppress_form_level_submit' => TRUE, '#access' => $this->getTranslationAccess($entity, 'delete')->isAllowed(), ); } @@ -430,11 +432,13 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En // Handle entity validation. if (isset($form['actions']['submit'])) { $form['actions']['submit']['#validate'][] = array($this, 'entityFormValidate'); + $form['actions']['submit']['#suppress_form_level_validate'] = TRUE; } // Handle entity deletion. if (isset($form['actions']['delete'])) { $form['actions']['delete']['#submit'][] = array($this, 'entityFormDelete'); + $form['actions']['delete']['#suppress_form_level_submit'] = TRUE; } } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 5f6c305..a994f6c 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -125,6 +125,7 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s '#value' => t('Configure'), '#limit_validation_errors' => array(array('editor')), '#submit' => array('editor_form_filter_admin_format_editor_configure'), + '#suppress_form_level_submit' => TRUE, '#ajax' => array( 'callback' => 'editor_form_filter_admin_form_ajax', 'wrapper' => 'editor-settings-wrapper', @@ -161,9 +162,9 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s $form['actions']['submit']['#submit'][] = array($plugin, 'settingsFormSubmit'); } - $form['actions']['submit']['#validate'][] = 'editor_form_filter_admin_format_validate'; - $form['actions']['submit']['#suppress_form_level_validate'] = TRUE; + $form['#validate'][] = 'editor_form_filter_admin_format_validate'; $form['actions']['submit']['#submit'][] = 'editor_form_filter_admin_format_submit'; + $form['actions']['submit']['#suppress_form_level_submit'] = TRUE; } /** diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index 94feeff..6809981 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -239,6 +239,7 @@ public function form(array $form, FormStateInterface $form_state) { '#value' => $this->t('Refresh'), '#op' => 'refresh_table', '#submit' => array(array($this, 'multistepSubmit')), + '#suppress_form_level_submit' => TRUE, '#ajax' => array( 'callback' => array($this, 'multistepAjax'), 'wrapper' => 'field-display-overview-wrapper', @@ -351,6 +352,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, arr // Base button element for the various plugin settings actions. $base_button = array( '#submit' => array(array($this, 'multistepSubmit')), + '#suppress_form_level_submit' => TRUE, '#ajax' => array( 'callback' => array($this, 'multistepAjax'), 'wrapper' => 'field-display-overview-wrapper', diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index bc58404..12a7fe4 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -173,7 +173,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Add'), '#validate' => array('::effectValidate'), - '#submit' => array('::submitForm', '::effectSave'), + '#submit' => ['::effectSave'], ), ), ), diff --git a/core/modules/language/src/Element/LanguageConfiguration.php b/core/modules/language/src/Element/LanguageConfiguration.php index aa6f94b..111aca8 100644 --- a/core/modules/language/src/Element/LanguageConfiguration.php +++ b/core/modules/language/src/Element/LanguageConfiguration.php @@ -80,6 +80,7 @@ public static function processLanguageConfiguration(&$element, FormStateInterfac $submit_name = isset($form['actions']['save_continue']) ? 'save_continue' : 'submit'; if (isset($form['actions'][$submit_name]['#submit']) && array_search('language_configuration_element_submit', $form['actions'][$submit_name]['#submit']) === FALSE) { $form['actions'][$submit_name]['#submit'][] = 'language_configuration_element_submit'; + $form['actions'][$submit_name]['#suppress_form_level_submit'] = TRUE; } elseif (array_search('language_configuration_element_submit', $form['#submit']) === FALSE) { $form['#submit'][] = 'language_configuration_element_submit'; diff --git a/core/modules/language/src/Form/LanguageAddForm.php b/core/modules/language/src/Form/LanguageAddForm.php index f0b1029..65485b3 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' => ['::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' => ['::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/locale/locale.module b/core/modules/locale/locale.module index 971b47d..4dc82d0 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -636,7 +636,9 @@ function locale_form_language_admin_overview_form_alter(&$form, FormStateInterfa */ function locale_form_language_admin_add_form_alter(&$form, FormStateInterface $form_state) { $form['predefined_submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit'; + $form['predefined_submit']['#suppress_form_level_submit'] = TRUE; $form['custom_language']['submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit'; + $form['custom_language']['submit']['#suppress_form_level_submit'] = TRUE; } /** @@ -678,6 +680,7 @@ function locale_form_language_admin_edit_form_alter(&$form, FormStateInterface $ '#default_value' => \Drupal::configFactory()->getEditable('locale.settings')->get('translate_english'), ); $form['actions']['submit']['#submit'][] = 'locale_form_language_admin_edit_form_alter_submit'; + $form['actions']['submit']['#suppress_form_level_submit'] = TRUE; } } diff --git a/core/modules/locale/src/Form/TranslateFilterForm.php b/core/modules/locale/src/Form/TranslateFilterForm.php index d283724..e50155b 100644 --- a/core/modules/locale/src/Form/TranslateFilterForm.php +++ b/core/modules/locale/src/Form/TranslateFilterForm.php @@ -75,6 +75,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Reset'), '#submit' => array('::resetForm'), + '#suppress_form_level_submit' => TRUE, ); } diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 95c9e3e..d1fe29b 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -336,6 +336,7 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { foreach (array_keys($form['actions']) as $action) { if (isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') { $form['actions'][$action]['#submit'][] = 'menu_ui_form_node_form_submit'; + $form['actions'][$action]['#suppress_form_level_submit'] = TRUE; } } } 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/path/src/Form/EditForm.php b/core/modules/path/src/Form/EditForm.php index 95d5e20..029d836 100644 --- a/core/modules/path/src/Form/EditForm.php +++ b/core/modules/path/src/Form/EditForm.php @@ -45,6 +45,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU '#type' => 'submit', '#value' => $this->t('Delete'), '#submit' => array('::deleteSubmit'), + '#suppress_form_level_submit' => TRUE, ); return $form; } diff --git a/core/modules/search/src/SearchPageListBuilder.php b/core/modules/search/src/SearchPageListBuilder.php index 7c3140c..2e9a970 100644 --- a/core/modules/search/src/SearchPageListBuilder.php +++ b/core/modules/search/src/SearchPageListBuilder.php @@ -194,6 +194,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Re-index site'), '#submit' => array('::searchAdminReindexSubmit'), + '#suppress_form_level_submit' => TRUE, ); $items = array(10, 20, 50, 100, 200, 500); @@ -280,7 +281,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Add new page'), '#validate' => array('::validateAddSearchPage'), + '#suppress_form_level_validate' => TRUE, '#submit' => array('::submitAddSearchPage'), + '#suppress_form_level_submit' => TRUE, '#limit_validation_errors' => array(array('search_type')), ); 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/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php index 03f16f5..ed1b523 100644 --- a/core/modules/simpletest/src/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php @@ -170,6 +170,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Clean environment'), '#submit' => array('simpletest_clean_environment'), + '#suppress_form_level_submit' => TRUE, ); return $form; diff --git a/core/modules/system/src/Form/CronForm.php b/core/modules/system/src/Form/CronForm.php index f906c70..2339175 100644 --- a/core/modules/system/src/Form/CronForm.php +++ b/core/modules/system/src/Form/CronForm.php @@ -100,6 +100,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => t('Run cron'), '#submit' => array('::submitCron'), + '#suppress_form_level_submit' => TRUE, ); $status = '
' . t('Last run: %cron-last ago.', array('%cron-last' => $this->dateFormatter->formatInterval(REQUEST_TIME - $this->state->get('system.cron_last')))) . '
'; diff --git a/core/modules/system/src/Form/PerformanceForm.php b/core/modules/system/src/Form/PerformanceForm.php index 9049c78..f7b0c80 100644 --- a/core/modules/system/src/Form/PerformanceForm.php +++ b/core/modules/system/src/Form/PerformanceForm.php @@ -115,6 +115,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => t('Clear all caches'), '#submit' => array('::submitCacheClear'), + '#suppress_form_level_submit' => TRUE, ); $form['caching'] = array( diff --git a/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php b/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php index 27327a4..584d29f 100644 --- a/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php +++ b/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php @@ -53,6 +53,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ), // Required for #limit_validation_errors. '#submit' => array(array($this, 'submitForm')), + '#suppress_form_level_submit' => TRUE, ); return $form; } diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php index 3704f15..1ce8a51 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php @@ -45,6 +45,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#value' => $this->t('Preview'), // No regular submit-handler. This form only works via JavaScript. '#submit' => array(), + '#suppress_form_level_submit' => TRUE, '#ajax' => array( // This means the ::preview() method on this class would be invoked in // case of a click event. However, since Drupal core's test runner only diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index d297945..c625efa 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -96,6 +96,7 @@ function form_test_form_user_register_form_alter(&$form, FormStateInterface $for '#type' => 'submit', '#value' => t('Rebuild'), '#submit' => array('form_test_user_register_form_rebuild'), + '#suppress_form_level_submit' => TRUE, ); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php index 293e320..cbe2bbe 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php @@ -64,18 +64,21 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#limit_validation_errors' => array(array('test')), '#submit' => array('::partialSubmitForm'), + '#suppress_form_level_submit' => TRUE, '#value' => t('Partial validate'), ); $form['actions']['partial_numeric_index'] = array( '#type' => 'submit', '#limit_validation_errors' => array(array('test_numeric_index', 0)), '#submit' => array('::partialSubmitForm'), + '#suppress_form_level_submit' => TRUE, '#value' => t('Partial validate (numeric index)'), ); $form['actions']['substring'] = array( '#type' => 'submit', '#limit_validation_errors' => array(array('test_substring', 'foo')), '#submit' => array('::partialSubmitForm'), + '#suppress_form_level_submit' => TRUE, '#value' => t('Partial validate (substring)'), ); $form['actions']['full'] = array( 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 f5d1667..4a142cb 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 @@ -75,6 +75,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // (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, ); $user_input = $form_state->getUserInput(); if (!empty($user_input['field_to_validate']) && $user_input['field_to_validate'] != 'all') { diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php index fba47e4..2b6f86c 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php @@ -54,6 +54,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => 'Add more', '#submit' => array('::addMoreSubmitForm'), + '#suppress_form_level_submit' => TRUE, ); } else { diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php index 60e0cdb..69e7e85 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php @@ -76,6 +76,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => 'Continue submit', '#submit' => array('::continueSubmitForm'), + '#suppress_form_level_submit' => TRUE, ); $form['submit'] = array( '#type' => 'submit', diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php index 9e7e391..a58809a 100644 --- a/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -354,6 +354,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Vocabular $form['actions']['reset_alphabetical'] = array( '#type' => 'submit', '#submit' => array('::submitReset'), + '#suppress_form_level_submit' => TRUE, '#value' => $this->t('Reset to alphabetical'), ); } diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 6fb8f6e..4c6db06 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -40,13 +40,6 @@ protected $entityQuery; /** - * The entity being used by this form. - * - * @var \Drupal\user\UserInterface - */ - protected $entity; - - /** * Constructs a new EntityForm object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -77,6 +70,7 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { + /** @var \Drupal\user\UserInterface $account */ $account = $this->entity; $user = $this->currentUser(); $config = \Drupal::config('user.settings'); @@ -179,6 +173,7 @@ public function form(array $form, FormStateInterface $form_state) { ); $form_state->set('user', $account); + $form['#validate'][] = 'user_validate_current_pass'; } } elseif (!$config->get('verify_mail') || $admin) { @@ -298,18 +293,6 @@ public function form(array $form, FormStateInterface $form_state) { } /** - * {@inheritdoc} - */ - protected function actions(array $form, FormStateInterface $form_state) { - $actions = parent::actions($form, $form_state); - if (!$this->entity->isAnonymous() && $this->currentUser()->id() == $this->entity->id()) { - $actions['submit']['#validate'][] = 'user_validate_current_pass'; - $actions['submit']['#suppress_form_level_validate'] = TRUE; - } - return $actions; - } - - /** * Alters the preferred language widget description. * * @param array $element diff --git a/core/modules/user/src/ProfileForm.php b/core/modules/user/src/ProfileForm.php index e119693..3a0f67a 100644 --- a/core/modules/user/src/ProfileForm.php +++ b/core/modules/user/src/ProfileForm.php @@ -38,6 +38,7 @@ protected function actions(array $form, FormStateInterface $form_state) { $element['delete']['#type'] = 'submit'; $element['delete']['#value'] = $this->t('Cancel account'); $element['delete']['#submit'] = array('::editCancelSubmit'); + $element['delete']['#suppress_form_level_submit'] = TRUE; $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $user->id() && $user->hasPermission('cancel account')) || $user->hasPermission('administer users')); return $element; diff --git a/core/modules/user/src/ProfileTranslationHandler.php b/core/modules/user/src/ProfileTranslationHandler.php index b24e634..37b37a9 100644 --- a/core/modules/user/src/ProfileTranslationHandler.php +++ b/core/modules/user/src/ProfileTranslationHandler.php @@ -38,6 +38,7 @@ protected function hasCreatedTime() { public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave'); + $form['actions']['submit']['#suppress_form_level_submit'] = TRUE; } /** diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index 9abf63e..fb17fc8 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -411,6 +411,7 @@ protected function showBuildGroupButton(&$form, FormStateInterface $form_state) '#type' => 'submit', '#value' => $this->t('Grouped filters'), '#submit' => array(array($this, 'buildGroupForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); $form['group_button']['radios']['radios']['#default_value'] = 0; @@ -421,6 +422,7 @@ protected function showBuildGroupButton(&$form, FormStateInterface $form_state) '#type' => 'submit', '#value' => $this->t('Single filter'), '#submit' => array(array($this, 'buildGroupForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); $form['group_button']['radios']['radios']['#default_value'] = 1; @@ -486,6 +488,7 @@ public function showExposeButton(&$form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Expose filter'), '#submit' => array(array($this, 'displayExposedForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); $form['expose_button']['checkbox']['checkbox']['#default_value'] = 0; @@ -499,6 +502,7 @@ public function showExposeButton(&$form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Hide filter'), '#submit' => array(array($this, 'displayExposedForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); $form['expose_button']['checkbox']['checkbox']['#default_value'] = 1; @@ -1074,6 +1078,7 @@ protected function buildExposedFiltersGroupForm(&$form, FormStateInterface $form '#type' => 'submit', '#value' => $this->t('Add another item'), '#submit' => array(array($this, 'addGroupForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); diff --git a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php index 8fe2b43..cb8918f 100644 --- a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php +++ b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php @@ -124,6 +124,7 @@ public function showExposeButton(&$form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Expose sort'), '#submit' => array(array($this, 'displayExposedForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); $form['expose_button']['checkbox']['checkbox']['#default_value'] = 0; @@ -137,6 +138,7 @@ public function showExposeButton(&$form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t('Hide sort'), '#submit' => array(array($this, 'displayExposedForm')), + '#suppress_form_level_submit' => TRUE, '#attributes' => array('class' => array('use-ajax-submit')), ); $form['expose_button']['checkbox']['checkbox']['#default_value'] = 1; diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index af256d2..84f8603 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -67,6 +67,7 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa // Hide this button when JavaScript is enabled. '#attributes' => array('class' => array('js-hide')), '#submit' => array('views_ui_nojs_submit'), + '#suppress_form_level_submit' => TRUE, // Add a process function to limit this button's validation errors to the // triggering element only. We have to do this in #process since until the // form API has added the #parents property to the triggering element for diff --git a/core/modules/views_ui/src/Form/AdvancedSettingsForm.php b/core/modules/views_ui/src/Form/AdvancedSettingsForm.php index d8cd1e2..52b9af5 100644 --- a/core/modules/views_ui/src/Form/AdvancedSettingsForm.php +++ b/core/modules/views_ui/src/Form/AdvancedSettingsForm.php @@ -54,6 +54,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'submit', '#value' => $this->t("Clear Views' cache"), '#submit' => array('::cacheSubmit'), + '#suppress_form_level_submit' => TRUE, ); $form['debug'] = array( diff --git a/core/modules/views_ui/src/Form/Ajax/AddHandler.php b/core/modules/views_ui/src/Form/Ajax/AddHandler.php index 8cc2e8c..45c5e87 100644 --- a/core/modules/views_ui/src/Form/Ajax/AddHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/AddHandler.php @@ -182,6 +182,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit'); }); $form['actions']['submit']['#submit'][] = array($view, 'submitItemAdd'); + $form['actions']['submit']['#suppress_form_level_submit'] = TRUE; return $form; } diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php index 28a7323..dd4e7b2 100644 --- a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php @@ -180,6 +180,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ '#type' => 'submit', '#value' => $this->t('Remove'), '#submit' => array(array($this, 'remove')), + '#suppress_form_level_submit' => TRUE, '#limit_validation_errors' => array(array('override')), '#ajax' => array( 'url' => Url::fromRoute('