function TermForm::buildEntity

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::buildEntity()
  2. 8.9.x core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::buildEntity()
  3. 10 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::buildEntity()

Overrides ContentEntityForm::buildEntity

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

File

core/modules/taxonomy/src/TermForm.php, line 154

Class

TermForm
Base for handler for taxonomy term edit forms.

Namespace

Drupal\taxonomy

Code

public function buildEntity(array $form, FormStateInterface $form_state) {
    $term = parent::buildEntity($form, $form_state);
    // Prevent leading and trailing spaces in term names.
    $term->setName(trim($term->getName()));
    // Assign parents with proper delta values starting from 0.
    $term->parent = array_values($form_state->getValue('parent'));
    return $term;
}

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