You are here

protected function EntityForm::init in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::init()
  2. 9 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::init()

Initialize the form state and the entity before the first form build.

1 call to EntityForm::init()
EntityForm::buildForm in core/lib/Drupal/Core/Entity/EntityForm.php
Form constructor.
3 methods override EntityForm::init()
ContentEntityForm::init in core/lib/Drupal/Core/Entity/ContentEntityForm.php
Initializes the form state and the entity before the first form build.
EntityDisplayModeFormBase::init in core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php
Initialize the form state and the entity before the first form build.
ViewFormBase::init in core/modules/views_ui/src/ViewFormBase.php
Initialize the form state and the entity before the first form build.

File

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

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

protected function init(FormStateInterface $form_state) {

  // Flag that this form has been initialized.
  $form_state
    ->set('entity_form_initialized', TRUE);

  // Prepare the entity to be presented in the entity form.
  $this
    ->prepareEntity();

  // Invoke the prepare form hooks.
  $this
    ->prepareInvokeAll('entity_prepare_form', $form_state);
  $this
    ->prepareInvokeAll($this->entity
    ->getEntityTypeId() . '_prepare_form', $form_state);
}