You are here

public function IndividualTypeForm::validate in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_contact/src/Form/IndividualTypeForm.php \Drupal\crm_core_contact\Form\IndividualTypeForm::validate()
  2. 8.2 modules/crm_core_contact/src/Form/IndividualTypeForm.php \Drupal\crm_core_contact\Form\IndividualTypeForm::validate()

File

modules/crm_core_contact/src/Form/IndividualTypeForm.php, line 98

Class

IndividualTypeForm
Form for edit individual types.

Namespace

Drupal\crm_core_contact\Form

Code

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