You are here

public function EntityForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

array The form structure.

Overrides FormInterface::buildForm

7 calls to EntityForm::buildForm()
ActionFormBase::buildForm in core/modules/action/src/ActionFormBase.php
Form constructor.
ContentEntityConfirmFormBase::buildForm in core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
Form constructor.
EntityConfirmFormBase::buildForm in core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php
Form constructor.
EntityDisplayModeAddForm::buildForm in core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php
Form constructor.
FieldStorageConfigEditForm::buildForm in core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php

... See full list

7 methods override EntityForm::buildForm()
ActionFormBase::buildForm in core/modules/action/src/ActionFormBase.php
Form constructor.
ContentEntityConfirmFormBase::buildForm in core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
Form constructor.
EntityConfirmFormBase::buildForm in core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php
Form constructor.
EntityDisplayModeAddForm::buildForm in core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php
Form constructor.
FieldStorageConfigEditForm::buildForm in core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php

... See full list

File

core/lib/Drupal/Core/Entity/EntityForm.php, line 106
Contains \Drupal\Core\Entity\EntityForm.

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

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

  // During the initial form build, add this form object to the form state and
  // allow for initial preparation before form building and processing.
  if (!$form_state
    ->has('entity_form_initialized')) {
    $this
      ->init($form_state);
  }

  // Ensure that edit forms have the correct cacheability metadata so they can
  // be cached.
  if (!$this->entity
    ->isNew()) {
    \Drupal::service('renderer')
      ->addCacheableDependency($form, $this->entity);
  }

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

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