public function EntityBrowserEditForm::buildEntity in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/Form/EntityBrowserEditForm.php \Drupal\entity_browser\Form\EntityBrowserEditForm::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 EntityForm::buildEntity
See also
\Drupal\Core\Entity\EntityFormInterface::getEntity()
File
- src/
Form/ EntityBrowserEditForm.php, line 403
Class
- EntityBrowserEditForm
- Class EntityBrowserEditForm.
Namespace
Drupal\entity_browser\FormCode
public function buildEntity(array $form, FormStateInterface $form_state) {
$this->entity
->setName($form_state
->getValue('name'))
->setLabel($form_state
->getValue('label'))
->setDisplay($form_state
->getValue('display'))
->setWidgetSelector($form_state
->getValue('widget_selector'))
->setSelectionDisplay($form_state
->getValue('selection_display'));
$subform_state = SubformState::createForSubform($form['display_wrapper']['display_configuration'], $form, $form_state);
$this->entity
->getDisplay()
->submitConfigurationForm($form, $subform_state);
$subform_state = SubformState::createForSubform($form['widget_selector_wrapper']['widget_selector_configuration'], $form, $form_state);
$this->entity
->getWidgetSelector()
->submitConfigurationForm($form, $subform_state);
$subform_state = SubformState::createForSubform($form['selection_display_wrapper']['selection_display_configuration'], $form, $form_state);
$this->entity
->getSelectionDisplay()
->submitConfigurationForm($form, $subform_state);
return parent::buildEntity($form, $form_state);
}