You are here

public function ProfileFormController::buildEntity in Profile 2 8

Builds an updated entity object based upon the submitted form values.

For building the updated entity object the form's entity is cloned and the submitted form values are copied to entity properties. The form's entity remains unchanged.

Parameters

array $form: A nested array form elements comprising the form.

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

Return value

\Drupal\Core\Entity\EntityInterface An updated copy of the form's entity object.

Overrides ContentEntityForm::buildEntity

See also

\Drupal\Core\Entity\EntityFormInterface::getEntity()

File

src/ProfileFormController.php, line 22
Contains \Drupal\profile\ProfileFormController.

Class

ProfileFormController
Form controller for profile forms.

Namespace

Drupal\profile

Code

public function buildEntity(array $form, FormStateInterface $form_state) {
  $entity = parent::buildEntity($form, $form_state);
  if ($entity
    ->isNew()) {
    $entity
      ->setCreatedTime(REQUEST_TIME);
  }
  return $entity;
}