You are here

public function CalendarEventTypeForm::validateForm in Opigno calendar event 8

Same name and namespace in other branches
  1. 3.x src/Form/CalendarEventTypeForm.php \Drupal\opigno_calendar_event\Form\CalendarEventTypeForm::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

src/Form/CalendarEventTypeForm.php, line 139

Class

CalendarEventTypeForm
Form handler for calendar event type forms.

Namespace

Drupal\opigno_calendar_event\Form

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,
    ]));
  }
}