function TermForm::buildEntity
Overrides ContentEntityForm::buildEntity
File
-
core/
modules/ taxonomy/ src/ TermForm.php, line 154
Class
- TermForm
- Base for handler for taxonomy term edit forms.
Namespace
Drupal\taxonomyCode
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.