You are here

public function GroupRoleForm::validateForm in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Form/GroupRoleForm.php \Drupal\group\Entity\Form\GroupRoleForm::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/Entity/Form/GroupRoleForm.php, line 99

Class

GroupRoleForm
Form controller for group role forms.

Namespace

Drupal\group\Entity\Form

Code

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

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