public function TermForm::buildEntity in Drupal 10
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::buildEntity()
- 9 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::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 ContentEntityForm::buildEntity
See also
\Drupal\Core\Entity\EntityFormInterface::getEntity()
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 148
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;
}