public function LayoutAddForm::buildEntity in Layout builder library 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 EntityForm::buildEntity
See also
\Drupal\Core\Entity\EntityFormInterface::getEntity()
File
- src/
Form/ LayoutAddForm.php, line 120
Class
- LayoutAddForm
- Defines a form for adding a layout library layout.
Namespace
Drupal\layout_library\FormCode
public function buildEntity(array $form, FormStateInterface $form_state) {
$entity = parent::buildEntity($form, $form_state);
list($entity_type_id, $bundle) = explode(':', $form_state
->getValue('_entity_type'), 2);
$entity
->set('targetEntityType', $entity_type_id);
$entity
->set('targetBundle', $bundle);
return $entity;
}