Loading core/lib/Drupal/Core/Form/FormBuilder.php +2 −0 Changes for core/lib/Drupal/Core/Form/FormBuilder.php: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1045,11 +1045,13 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // Provide a selector usable by JavaScript. As the ID is unique, it's not // possible to rely on it in JavaScript. $element['#attributes']['data-drupal-selector'] = Html::getId($unprocessed_id); $element['#wrapper_attributes']['data-drupal-wrapper-selector'] = Html::getId($unprocessed_id); } else { // Provide a selector usable by JavaScript. As the ID is unique, it's not // possible to rely on it in JavaScript. $element['#attributes']['data-drupal-selector'] = Html::getId($element['#id']); $element['#wrapper_attributes']['data-drupal-wrapper-selector'] = Html::getId($element['#id']); } // Add the aria-describedby attribute to associate the form control with its Loading core/modules/config/src/Form/ConfigSingleExportForm.php +5 −8 Changes for core/modules/config/src/Form/ConfigSingleExportForm.php: 5 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -101,8 +101,8 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c (new Htmx()) ->post($form_url) ->onlyMainContent() ->select('*:has(>select[name="config_name"])') ->target('*:has(>select[name="config_name"])') ->select('[data-drupal-wrapper-selector="edit-config-name"]') ->target('[data-drupal-wrapper-selector="edit-config-name"]') ->swap('outerHTML') ->applyTo($form['config_type']); Loading @@ -119,8 +119,8 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c (new Htmx()) ->post($form_url) ->onlyMainContent() ->select('[data-export-wrapper]') ->target('[data-export-wrapper]') ->select('[data-drupal-wrapper-selector="edit-export"]') ->target('[data-drupal-wrapper-selector="edit-export"]') ->swap('outerHTML') ->applyTo($form['config_name']); Loading @@ -128,9 +128,6 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c '#title' => $this->t('Here is your configuration:'), '#type' => 'textarea', '#rows' => 24, '#wrapper_attributes' => [ 'data-export-wrapper' => TRUE, ], ]; $pushUrl = FALSE; Loading @@ -139,7 +136,7 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c $form = $this->updateConfigurationType($form, $form_state); // Also update the empty export element "out of band". (new Htmx()) ->swapOob('outerHTML:[data-export-wrapper]') ->swapOob('outerHTML:[data-drupal-wrapper-selector="edit-export"]') ->applyTo($form['export'], '#wrapper_attributes'); $pushUrl = Url::fromRoute('config.export_single', ['config_type' => $default_type, 'config_name' => '']); } Loading core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php +2 −2 Changes for core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ namespace Drupal\Tests\config\Functional; use Drupal\Component\Utility\Html; use Drupal\Tests\BrowserTestBase; use Drupal\user\Entity\Role; use PHPUnit\Framework\Attributes\Group; Loading Loading @@ -60,7 +59,8 @@ public function testDraggableList(): void { $role->set('label', $role_name)->save(); $this->drupalGet('admin/people/roles'); $this->assertSession()->responseContains('<td>' . Html::escape($role_name)); $roleElementLabel = $this->cssSelect('td[data-drupal-wrapper-selector="edit-entities-role-0-label"]'); $this->assertEquals($role_name, $roleElementLabel[0]->getText()); } } core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php +5 −0 Changes for core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -90,6 +90,11 @@ public function testAjaxOnExportPage(): void { $this->assertSession()->fieldValueEquals('export', ''); // Check that the export is emptied again when selecting a config type. // First select a config name to populate the export. $page->selectFieldOption('config_name', 'system.site'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->fieldValueNotEquals('export', ''); // Then select a config type to empty the export. $page->selectFieldOption('config_type', 'Action'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->fieldValueEquals('export', ''); Loading Loading
core/lib/Drupal/Core/Form/FormBuilder.php +2 −0 Changes for core/lib/Drupal/Core/Form/FormBuilder.php: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1045,11 +1045,13 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // Provide a selector usable by JavaScript. As the ID is unique, it's not // possible to rely on it in JavaScript. $element['#attributes']['data-drupal-selector'] = Html::getId($unprocessed_id); $element['#wrapper_attributes']['data-drupal-wrapper-selector'] = Html::getId($unprocessed_id); } else { // Provide a selector usable by JavaScript. As the ID is unique, it's not // possible to rely on it in JavaScript. $element['#attributes']['data-drupal-selector'] = Html::getId($element['#id']); $element['#wrapper_attributes']['data-drupal-wrapper-selector'] = Html::getId($element['#id']); } // Add the aria-describedby attribute to associate the form control with its Loading
core/modules/config/src/Form/ConfigSingleExportForm.php +5 −8 Changes for core/modules/config/src/Form/ConfigSingleExportForm.php: 5 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -101,8 +101,8 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c (new Htmx()) ->post($form_url) ->onlyMainContent() ->select('*:has(>select[name="config_name"])') ->target('*:has(>select[name="config_name"])') ->select('[data-drupal-wrapper-selector="edit-config-name"]') ->target('[data-drupal-wrapper-selector="edit-config-name"]') ->swap('outerHTML') ->applyTo($form['config_type']); Loading @@ -119,8 +119,8 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c (new Htmx()) ->post($form_url) ->onlyMainContent() ->select('[data-export-wrapper]') ->target('[data-export-wrapper]') ->select('[data-drupal-wrapper-selector="edit-export"]') ->target('[data-drupal-wrapper-selector="edit-export"]') ->swap('outerHTML') ->applyTo($form['config_name']); Loading @@ -128,9 +128,6 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c '#title' => $this->t('Here is your configuration:'), '#type' => 'textarea', '#rows' => 24, '#wrapper_attributes' => [ 'data-export-wrapper' => TRUE, ], ]; $pushUrl = FALSE; Loading @@ -139,7 +136,7 @@ public function buildForm(array $form, FormStateInterface $form_state, string $c $form = $this->updateConfigurationType($form, $form_state); // Also update the empty export element "out of band". (new Htmx()) ->swapOob('outerHTML:[data-export-wrapper]') ->swapOob('outerHTML:[data-drupal-wrapper-selector="edit-export"]') ->applyTo($form['export'], '#wrapper_attributes'); $pushUrl = Url::fromRoute('config.export_single', ['config_type' => $default_type, 'config_name' => '']); } Loading
core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php +2 −2 Changes for core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ namespace Drupal\Tests\config\Functional; use Drupal\Component\Utility\Html; use Drupal\Tests\BrowserTestBase; use Drupal\user\Entity\Role; use PHPUnit\Framework\Attributes\Group; Loading Loading @@ -60,7 +59,8 @@ public function testDraggableList(): void { $role->set('label', $role_name)->save(); $this->drupalGet('admin/people/roles'); $this->assertSession()->responseContains('<td>' . Html::escape($role_name)); $roleElementLabel = $this->cssSelect('td[data-drupal-wrapper-selector="edit-entities-role-0-label"]'); $this->assertEquals($role_name, $roleElementLabel[0]->getText()); } }
core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php +5 −0 Changes for core/modules/config/tests/src/FunctionalJavascript/ConfigExportTest.php: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -90,6 +90,11 @@ public function testAjaxOnExportPage(): void { $this->assertSession()->fieldValueEquals('export', ''); // Check that the export is emptied again when selecting a config type. // First select a config name to populate the export. $page->selectFieldOption('config_name', 'system.site'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->fieldValueNotEquals('export', ''); // Then select a config type to empty the export. $page->selectFieldOption('config_type', 'Action'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->fieldValueEquals('export', ''); Loading