protected function EntityFormController::init

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

2 calls to EntityFormController::init()
EntityFormController::buildForm in drupal/core/lib/Drupal/Core/Entity/EntityFormController.php
Form constructor.
ViewFormControllerBase::init in drupal/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php
Initialize the form state and the entity before the first form build.
1 method overrides EntityFormController::init()
ViewFormControllerBase::init in drupal/core/modules/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php
Initialize the form state and the entity before the first form build.

File

drupal/core/lib/Drupal/Core/Entity/EntityFormController.php, line 119
Contains \Drupal\Core\Entity\EntityFormController.

Class

EntityFormController
Base class for entity form controllers.

Namespace

Drupal\Core\Entity

Code

protected function init(array &$form_state) {

  // Add the controller to the form state so it can be easily accessed by
  // module-provided form handlers there.
  $form_state['controller'] = $this;
  $this
    ->prepareEntity();

  // @todo Allow the usage of different form modes by exposing a hook and the
  // UI for them.
  $form_display = entity_get_render_form_display($this->entity, 'default');

  // Let modules alter the form display.
  $form_display_context = array(
    'entity_type' => $this->entity
      ->entityType(),
    'bundle' => $this->entity
      ->bundle(),
    'form_mode' => 'default',
  );
  \Drupal::moduleHandler()
    ->alter('entity_form_display', $form_display, $form_display_context);
  $this
    ->setFormDisplay($form_display, $form_state);
}