From cb2e043f53fcf05dd20d16479d188e042e493f75 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Thu, 10 Sep 2020 14:36:16 +1000
Subject: [PATCH] Issue #315176 by Dave Reid, andypost, franz, sun, Alan D.:
 Clean-up remains of $form['array_filter'] hack with array_filter in book
 module

(cherry picked from commit 65b6ffc9069afa835e4d3b14065a934c089f513b)
---
 core/modules/book/src/Form/BookSettingsForm.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/core/modules/book/src/Form/BookSettingsForm.php b/core/modules/book/src/Form/BookSettingsForm.php
index 3189ef519e2f..19edbad09a0d 100644
--- a/core/modules/book/src/Form/BookSettingsForm.php
+++ b/core/modules/book/src/Form/BookSettingsForm.php
@@ -47,7 +47,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#options' => $types,
       '#required' => TRUE,
     ];
-    $form['array_filter'] = ['#type' => 'value', '#value' => TRUE];
 
     return parent::buildForm($form, $form_state);
   }
@@ -56,7 +55,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    * {@inheritdoc}
    */
   public function validateForm(array &$form, FormStateInterface $form_state) {
-    $child_type = $form_state->getValue('book_child_type');
+    $child_type = array_filter($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')]));
     }
@@ -76,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', $form_state->getValue('book_child_type'))
+      ->set('child_type', array_filter($form_state->getValue('book_child_type')))
       ->save();
 
     parent::submitForm($form, $form_state);
-- 
GitLab