You are here

public function FieldStorageConfigEditForm::buildEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::buildEntity()
  2. 9 core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::buildEntity()

Builds an updated entity object based upon the submitted form values.

For building the updated entity object the form's entity is cloned and the submitted form values are copied to entity properties. The form's entity remains unchanged.

Parameters

array $form: A nested array form elements comprising the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

\Drupal\Core\Entity\EntityInterface An updated copy of the form's entity object.

Overrides EntityForm::buildEntity

See also

\Drupal\Core\Entity\EntityFormInterface::getEntity()

File

core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php, line 214

Class

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

Namespace

Drupal\field_ui\Form

Code

public function buildEntity(array $form, FormStateInterface $form_state) {

  // Save field cardinality.
  if (!$this
    ->getEnforcedCardinality() && $form_state
    ->getValue('cardinality') === 'number' && $form_state
    ->getValue('cardinality_number')) {
    $form_state
      ->setValue('cardinality', $form_state
      ->getValue('cardinality_number'));
  }
  return parent::buildEntity($form, $form_state);
}