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

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

6 calls to ContentEntityForm::form()
BlockContentForm::form in core/modules/block_content/src/BlockContentForm.php
Gets the actual form array to be built.
EntityTestForm::form in core/modules/system/tests/modules/entity_test/src/EntityTestForm.php
Gets the actual form array to be built.
MediaForm::form in core/modules/media/src/MediaForm.php
Gets the actual form array to be built.
MessageForm::form in core/modules/contact/src/MessageForm.php
Gets the actual form array to be built.
NodeForm::form in core/modules/node/src/NodeForm.php
Gets the actual form array to be built.

... See full list

8 methods override ContentEntityForm::form()
BlockContentForm::form in core/modules/block_content/src/BlockContentForm.php
Gets the actual form array to be built.
BookOutlineForm::form in core/modules/book/src/Form/BookOutlineForm.php
Gets the actual form array to be built.
ContentEntityConfirmFormBase::form in core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
Gets the actual form array to be built.
EntityTestForm::form in core/modules/system/tests/modules/entity_test/src/EntityTestForm.php
Gets the actual form array to be built.
MediaForm::form in core/modules/media/src/MediaForm.php
Gets the actual form array to be built.

... See full list

File

core/lib/Drupal/Core/Entity/ContentEntityForm.php, line 101

Class

ContentEntityForm
Entity form variant for content entity types.

Namespace

Drupal\Core\Entity

Code

public function form(array $form, FormStateInterface $form_state) {
  if ($this
    ->showRevisionUi()) {

    // Advanced tab must be the first, because other fields rely on that.
    if (!isset($form['advanced'])) {
      $form['advanced'] = [
        '#type' => 'vertical_tabs',
        '#weight' => 99,
      ];
    }
  }
  $form = parent::form($form, $form_state);

  // Content entity forms do not use the parent's #after_build callback
  // because they only need to rebuild the entity in the validation and the
  // submit handler because Field API uses its own #after_build callback for
  // its widgets.
  unset($form['#after_build']);
  $this
    ->getFormDisplay($form_state)
    ->buildForm($this->entity, $form, $form_state);

  // Allow modules to act before and after form language is updated.
  $form['#entity_builders']['update_form_langcode'] = '::updateFormLangcode';
  if ($this
    ->showRevisionUi()) {
    $this
      ->addRevisionableFormFields($form);
  }
  $form['footer'] = [
    '#type' => 'container',
    '#weight' => 99,
    '#attributes' => [
      'class' => [
        'entity-content-form-footer',
      ],
    ],
    '#optional' => TRUE,
  ];
  return $form;
}