You are here

public function FieldStorageConfigEditForm::validateForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::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/field_ui/src/Form/FieldStorageConfigEditForm.php, line 149
Contains \Drupal\field_ui\Form\FieldStorageConfigEditForm.

Class

FieldStorageConfigEditForm
Provides a form for the "field storage" edit page.

Namespace

Drupal\field_ui\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  // Validate field cardinality.
  if ($form_state
    ->getValue('cardinality') === 'number' && !$form_state
    ->getValue('cardinality_number')) {
    $form_state
      ->setErrorByName('cardinality_number', $this
      ->t('Number of values is required.'));
  }
}