You are here

public function BookingBundleForm::validateForm in Booking and Availability Management Tools for Drupal 8

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

modules/bat_booking/src/BookingBundleForm.php, line 98
Contains \Drupal\bat_booking\BookingBundleForm.

Class

BookingBundleForm
Form handler for type bundle forms.

Namespace

Drupal\bat_booking

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $id = trim($form_state
    ->getValue('type'));

  // '0' is invalid, since elsewhere we check it using empty().
  if ($id == '0') {
    $form_state
      ->setErrorByName('type', $this
      ->t("Invalid machine-readable name. Enter a name other than %invalid.", [
      '%invalid' => $id,
    ]));
  }
}