You are here

public function ForumForm::buildEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/forum/src/Form/ForumForm.php \Drupal\forum\Form\ForumForm::buildEntity()

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 TermForm::buildEntity

See also

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

1 call to ForumForm::buildEntity()
ContainerForm::buildEntity in core/modules/forum/src/Form/ContainerForm.php
Builds an updated entity object based upon the submitted form values.
1 method overrides ForumForm::buildEntity()
ContainerForm::buildEntity in core/modules/forum/src/Form/ContainerForm.php
Builds an updated entity object based upon the submitted form values.

File

core/modules/forum/src/Form/ForumForm.php, line 63

Class

ForumForm
Base form for forum term edit forms.

Namespace

Drupal\forum\Form

Code

public function buildEntity(array $form, FormStateInterface $form_state) {
  $term = parent::buildEntity($form, $form_state);

  // Assign parents from forum parent select field.
  $term->parent = [
    $form_state
      ->getValue([
      'parent',
      0,
    ]),
  ];
  return $term;
}