From ef97c53bf589a64bf5a971108553b37282c8108d Mon Sep 17 00:00:00 2001 From: nod_ <nod_@598310.no-reply.drupal.org> Date: Thu, 11 Apr 2024 21:54:57 +0200 Subject: [PATCH] Issue #3303557 by Binoli Lalani, quietone, catch, Tom Konda, smustgrave: Deprecate and remove the AJAX replace method (cherry picked from commit 553398453ca8a55214f5636864de365cb4831bee) --- core/lib/Drupal/Core/Render/Element/RenderElementBase.php | 1 + .../ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php | 4 ++-- .../form_test/src/Form/FormTestMachineNameValidationForm.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Render/Element/RenderElementBase.php b/core/lib/Drupal/Core/Render/Element/RenderElementBase.php index 0ba624f743c0..84230b5c14f0 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElementBase.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElementBase.php @@ -374,6 +374,7 @@ public static function preRenderAjaxForm($element) { // @todo Legacy support. Remove in Drupal 8. if (isset($settings['method']) && $settings['method'] == 'replace') { + @trigger_error('Using "replace" as the method in #ajax property is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use "replaceWith" instead. See https://www.drupal.org/project/drupal/issues/3303557', E_USER_DEPRECATED); $settings['method'] = 'replaceWith'; } diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php index 3774d3c57551..b63f48144a11 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php @@ -31,7 +31,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#ajax' => [ 'callback' => 'ajax_forms_test_validation_form_callback', 'wrapper' => 'message_area', - 'method' => 'replace', + 'method' => 'replaceWith', ], '#suffix' => '<div id="message_area"></div>', ]; @@ -44,7 +44,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#ajax' => [ 'callback' => 'ajax_forms_test_validation_number_form_callback', 'wrapper' => 'message_area_number', - 'method' => 'replace', + 'method' => 'replaceWith', ], '#suffix' => '<div id="message_area_number"></div>', ]; diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php index 63350a65fc2a..cb854c4b7bf0 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestMachineNameValidationForm.php @@ -77,7 +77,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#ajax' => [ 'callback' => '::buildAjaxSnackConfigureForm', 'wrapper' => 'snack-config-form', - 'method' => 'replace', + 'method' => 'replaceWith', 'effect' => 'fade', ], ]; -- GitLab