Issue #315176 by Dave Reid, andypost, franz, sun, Alan D.: Clean-up remains of $form['array_filter'] hack with array_filter in book module

merge-requests/25/head
Lee Rowlands 2020-09-10 14:36:16 +10:00
parent 6e451a1fba
commit 65b6ffc906
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
1 changed files with 2 additions and 3 deletions

View File

@ -47,7 +47,6 @@ class BookSettingsForm extends ConfigFormBase {
'#options' => $types,
'#required' => TRUE,
];
$form['array_filter'] = ['#type' => 'value', '#value' => TRUE];
return parent::buildForm($form, $form_state);
}
@ -56,7 +55,7 @@ class BookSettingsForm extends ConfigFormBase {
* {@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 @@ class BookSettingsForm extends ConfigFormBase {
$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);