You are here

public function BookSettingsForm::validateForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/src/Form/BookSettingsForm.php \Drupal\book\Form\BookSettingsForm::validateForm()
  2. 9 core/modules/book/src/Form/BookSettingsForm.php \Drupal\book\Form\BookSettingsForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

core/modules/book/src/Form/BookSettingsForm.php, line 57

Class

BookSettingsForm
Configure book settings for this site.

Namespace

Drupal\book\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $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'),
    ]));
  }
  parent::validateForm($form, $form_state);
}