diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 382bba1..5e36b19 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -244,9 +244,9 @@ public function buildForm($form_id, FormStateInterface &$form_state) { } } - // If this form should post to the original URL, disable all form redirects. + // If this form is an AJAX request, disable all form redirects. $request = $this->requestStack->getCurrentRequest(); - if ($post_to_original_url = $request->query->has(static::POST_TO_ORIGINAL_URL)) { + if ($ajax_form_request = $request->query->has(static::AJAX_FORM_REQUEST)) { $form_state->disableRedirect(); } @@ -263,14 +263,14 @@ public function buildForm($form_id, FormStateInterface &$form_state) { // can use it to know or update information about the state of the form. $response = $this->processForm($form_id, $form, $form_state); - // After processing the form, if this is to be posted to the original URL, - // interrupt form rendering and return by throwing an exception that - // contains the processed form and form state. This exception will be caught - // by \Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber::onException() - // and then passed through + // After processing the form, if this is an AJAX form request, interrupt + // form rendering and return by throwing an exception that contains the + // processed form and form state. This exception will be caught by + // \Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber::onException() and + // then passed through // \Drupal\Core\Form\FormAjaxResponseBuilderInterface::buildResponse() to // build a proper AJAX response. - if ($post_to_original_url) { + if ($ajax_form_request) { throw new FormAjaxException($form, $form_state); } diff --git a/core/lib/Drupal/Core/Form/FormBuilderInterface.php b/core/lib/Drupal/Core/Form/FormBuilderInterface.php index 76d3342..9178278 100644 --- a/core/lib/Drupal/Core/Form/FormBuilderInterface.php +++ b/core/lib/Drupal/Core/Form/FormBuilderInterface.php @@ -13,9 +13,9 @@ interface FormBuilderInterface { /** - * Request key for a form that will post to original URL on AJAX submission. + * Request key for a form that was triggered via AJAX. */ - const POST_TO_ORIGINAL_URL = 'post_to_original_url'; + const AJAX_FORM_REQUEST = 'ajax_form'; /** * Determines the ID of a form. diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 623f418..039a19f 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -241,7 +241,7 @@ public static function preRenderAjaxForm($element) { // re-rendering. For that, we have a special 'system/ajax' route. if (isset($settings['callback']) && !isset($settings['url'])) { $settings['url'] = Url::fromRoute(''); - $settings['options']['query'][FormBuilderInterface::POST_TO_ORIGINAL_URL] = TRUE; + $settings['options']['query'][FormBuilderInterface::AJAX_FORM_REQUEST] = TRUE; } $settings += array( 'url' => NULL, diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php index 603cfa0..fbe586c 100644 --- a/core/modules/system/src/Tests/Ajax/DialogTest.php +++ b/core/modules/system/src/Tests/Ajax/DialogTest.php @@ -166,7 +166,7 @@ public function testDialog() { 'edit-preview' => [ 'callback' => '::preview', 'event' => 'click', - 'url' => Url::fromRoute('ajax_test.dialog_form')->setOption('query', [FormBuilderInterface::POST_TO_ORIGINAL_URL => TRUE])->toString(), + 'url' => Url::fromRoute('ajax_test.dialog_form')->setOption('query', [FormBuilderInterface::AJAX_FORM_REQUEST => TRUE])->toString(), 'dialogType' => 'ajax', 'submit' => [ '_triggering_element_name' => 'op',