function EntityForm::afterBuild

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::afterBuild()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::afterBuild()
  3. 10 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::afterBuild()

Form element #after_build callback: Updates the entity with submitted data.

Updates the internal $this->entity object with submitted values when the form is being rebuilt (e.g. submitted via AJAX), so that subsequent processing (e.g. AJAX callbacks) can rely on it.

1 call to EntityForm::afterBuild()
FieldConfigEditForm::afterBuild in core/modules/field_ui/src/Form/FieldConfigEditForm.php
Form element #after_build callback: Updates the entity with submitted data.
1 method overrides EntityForm::afterBuild()
FieldConfigEditForm::afterBuild in core/modules/field_ui/src/Form/FieldConfigEditForm.php
Form element #after_build callback: Updates the entity with submitted data.

File

core/lib/Drupal/Core/Entity/EntityForm.php, line 167

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

public function afterBuild(array $element, FormStateInterface $form_state) {
    // Rebuild the entity if #after_build is being called as part of a form
    // rebuild, i.e. if we are processing input.
    if ($form_state->isProcessingInput()) {
        $this->entity = $this->buildEntity($element, $form_state);
    }
    return $element;
}

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