public function EntityFormController::build

Implements Drupal\Core\Entity\EntityFormControllerInterface::build().

Overrides EntityFormControllerInterface::build

File

drupal/core/lib/Drupal/Core/Entity/EntityFormController.php, line 38
Definition of Drupal\Core\Entity\EntityFormController.

Class

EntityFormController
Base class for entity form controllers.

Namespace

Drupal\Core\Entity

Code

public function build(array $form, array &$form_state, EntityInterface $entity) {

  // During the initial form build, add the entity to the form state for use
  // during form building and processing. During a rebuild, use what is in the
  // form state.
  if (!$this
    ->getEntity($form_state)) {
    $this
      ->init($form_state, $entity);
  }

  // Retrieve the form array using the possibly updated entity in form state.
  $entity = $this
    ->getEntity($form_state);
  $form = $this
    ->form($form, $form_state, $entity);

  // Retrieve and add the form actions array.
  $actions = $this
    ->actionsElement($form, $form_state);
  if (!empty($actions)) {
    $form['actions'] = $actions;
  }
  return $form;
}