You are here

public function BookAdminEditForm::validateForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/src/Form/BookAdminEditForm.php \Drupal\book\Form\BookAdminEditForm::validateForm()
  2. 9 core/modules/book/src/Form/BookAdminEditForm.php \Drupal\book\Form\BookAdminEditForm::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/BookAdminEditForm.php, line 98

Class

BookAdminEditForm
Provides a form for administering a single book's hierarchy.

Namespace

Drupal\book\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('tree_hash') != $form_state
    ->getValue('tree_current_hash')) {
    $form_state
      ->setErrorByName('', $this
      ->t('This book has been modified by another user, the changes could not be saved.'));
  }
}