function FieldConfigEditForm::validateForm

Same name and namespace in other branches
  1. 9 core/modules/field_ui/src/Form/FieldConfigEditForm.php \Drupal\field_ui\Form\FieldConfigEditForm::validateForm()
  2. 8.9.x core/modules/field_ui/src/Form/FieldConfigEditForm.php \Drupal\field_ui\Form\FieldConfigEditForm::validateForm()
  3. 10 core/modules/field_ui/src/Form/FieldConfigEditForm.php \Drupal\field_ui\Form\FieldConfigEditForm::validateForm()

Overrides FormBase::validateForm

File

core/modules/field_ui/src/Form/FieldConfigEditForm.php, line 329

Class

FieldConfigEditForm
Provides a form for the field settings form.

Namespace

Drupal\field_ui\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);
    $field_storage_form = $this->entityTypeManager
        ->getFormObject('field_storage_config', $this->operation);
    $field_storage_form->setEntity($this->entity
        ->getFieldStorageDefinition());
    $subform_state = SubformState::createForSubform($form['field_storage']['subform'], $form, $form_state, $field_storage_form);
    $field_storage_form->validateForm($form['field_storage']['subform'], $subform_state);
    // Make sure that the default value form is validated using the field
    // configuration that was just submitted.
    $field_config = $this->buildEntity($form, $form_state);
    if (isset($form['default_value']) && (!isset($form['set_default_value']) || $form_state->getValue('set_default_value'))) {
        $items = $this->getTypedData($field_config, $form['#entity']);
        $items->defaultValuesFormValidate($form['default_value'], $form, $form_state);
    }
    // The form is rendered based on the entity property, meaning that it must
    // be updated based on the latest form state even though it might be invalid
    // at this point.
    $this->entity = $this->buildEntity($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.