Commit 80102634 authored by catch's avatar catch

Issue #3181173 by longwave, pefferen, JD_1, larowlan: Drupal 8.9.7 breaks Book...

Issue #3181173 by longwave, pefferen, JD_1, larowlan: Drupal 8.9.7 breaks Book Settings Form Validation

(cherry picked from commit 23116573)
parent b966efe5
...@@ -55,7 +55,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -55,7 +55,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validateForm(array &$form, FormStateInterface $form_state) { 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])) { 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')])); $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) { ...@@ -75,7 +75,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('book.settings') $this->config('book.settings')
// Remove unchecked types. // Remove unchecked types.
->set('allowed_types', $allowed_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(); ->save();
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
......
...@@ -644,4 +644,12 @@ public function testBookNavigationBlockOnUnpublishedBook() { ...@@ -644,4 +644,12 @@ public function testBookNavigationBlockOnUnpublishedBook() {
$this->assertText($this->book->label(), 'Unpublished book with "Show block only on book pages" book navigation settings.'); $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');
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment