function ContentEntityForm::buildEntity

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::buildEntity()
  2. 10 core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::buildEntity()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::buildEntity()

Overrides EntityForm::buildEntity

5 calls to ContentEntityForm::buildEntity()
AccountForm::buildEntity in core/modules/user/src/AccountForm.php
Builds an updated entity object based upon the submitted form values.
CommentForm::buildEntity in core/modules/comment/src/CommentForm.php
Builds an updated entity object based upon the submitted form values.
ContentEntityForm::validateForm in core/lib/Drupal/Core/Entity/ContentEntityForm.php
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…
MenuLinkContentForm::buildEntity in core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
Builds an updated entity object based upon the submitted form values.
TermForm::buildEntity in core/modules/taxonomy/src/TermForm.php
Builds an updated entity object based upon the submitted form values.
4 methods override ContentEntityForm::buildEntity()
AccountForm::buildEntity in core/modules/user/src/AccountForm.php
Builds an updated entity object based upon the submitted form values.
CommentForm::buildEntity in core/modules/comment/src/CommentForm.php
Builds an updated entity object based upon the submitted form values.
MenuLinkContentForm::buildEntity in core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
Builds an updated entity object based upon the submitted form values.
TermForm::buildEntity in core/modules/taxonomy/src/TermForm.php
Builds an updated entity object based upon the submitted form values.

File

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

Class

ContentEntityForm
Entity form variant for content entity types.

Namespace

Drupal\Core\Entity

Code

public function buildEntity(array $form, FormStateInterface $form_state) {
    
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = parent::buildEntity($form, $form_state);
    // Mark the entity as requiring validation.
    $entity->setValidationRequired(!$form_state->getTemporaryValue('entity_validated'));
    // Save as a new revision if requested to do so.
    if ($this->showRevisionUi() && !$form_state->isValueEmpty('revision')) {
        $entity->setNewRevision();
        if ($entity instanceof RevisionLogInterface) {
            // If a new revision is created, save the current user as
            // revision author.
            $entity->setRevisionUserId($this->currentUser()
                ->id());
            $entity->setRevisionCreationTime($this->time
                ->getRequestTime());
        }
    }
    return $entity;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.