From 8010263478745d433a4ef6a02ad35ed54e260f64 Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 9 Nov 2020 10:08:38 +0000 Subject: [PATCH] Issue #3181173 by longwave, pefferen, JD_1, larowlan: Drupal 8.9.7 breaks Book Settings Form Validation (cherry picked from commit 231165730f6e65c3a93fa1709a51d5337ef5d12c) --- core/modules/book/src/Form/BookSettingsForm.php | 4 ++-- core/modules/book/tests/src/Functional/BookTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/modules/book/src/Form/BookSettingsForm.php b/core/modules/book/src/Form/BookSettingsForm.php index 19edbad09a..3a92ba9a82 100644 --- a/core/modules/book/src/Form/BookSettingsForm.php +++ b/core/modules/book/src/Form/BookSettingsForm.php @@ -55,7 +55,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - $child_type = array_filter($form_state->getValue('book_child_type')); + $child_type = $form_state->getValue('book_child_type'); if ($form_state->isValueEmpty(['book_allowed_types', $child_type])) { $form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', ['%add-child' => $this->t('Add child page')])); } @@ -75,7 +75,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('book.settings') // Remove unchecked types. ->set('allowed_types', $allowed_types) - ->set('child_type', array_filter($form_state->getValue('book_child_type'))) + ->set('child_type', $form_state->getValue('book_child_type')) ->save(); parent::submitForm($form, $form_state); diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 24e35e7551..3733699975 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -644,4 +644,12 @@ public function testBookNavigationBlockOnUnpublishedBook() { $this->assertText($this->book->label(), 'Unpublished book with "Show block only on book pages" book navigation settings.'); } + /** + * Tests that the book settings form can be saved without error. + */ + public function testSettingsForm() { + $this->drupalLogin($this->adminUser); + $this->drupalPostForm('admin/structure/book/settings', [], 'Save configuration'); + } + } -- GitLab