function EntityForm::copyFormValuesToEntity
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::copyFormValuesToEntity()
- 8.9.x core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::copyFormValuesToEntity()
- 10 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::copyFormValuesToEntity()
Copies top-level form values to entity properties.
This should not change existing entity properties that are not being edited by this form.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.
array $form: A nested array of form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
See also
\Drupal\Core\Form\ConfigFormBase::copyFormValuesToConfig()
3 calls to EntityForm::copyFormValuesToEntity()
- BlockContentTypeForm::copyFormValuesToEntity in core/
modules/ block_content/ src/ BlockContentTypeForm.php - EntityForm::buildEntity in core/
lib/ Drupal/ Core/ Entity/ EntityForm.php - FieldConfigEditForm::copyFormValuesToEntity in core/
modules/ field_ui/ src/ Form/ FieldConfigEditForm.php
11 methods override EntityForm::copyFormValuesToEntity()
- BlockContentTypeForm::copyFormValuesToEntity in core/
modules/ block_content/ src/ BlockContentTypeForm.php - ContentEntityForm::copyFormValuesToEntity in core/
lib/ Drupal/ Core/ Entity/ ContentEntityForm.php - EntityDisplayFormBase::copyFormValuesToEntity in core/
modules/ field_ui/ src/ Form/ EntityDisplayFormBase.php - FieldConfigEditForm::copyFormValuesToEntity in core/
modules/ field_ui/ src/ Form/ FieldConfigEditForm.php - LanguageAddForm::copyFormValuesToEntity in core/
modules/ language/ src/ Form/ LanguageAddForm.php
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityForm.php, line 329
Class
- EntityForm
- Base class for entity forms.
Namespace
Drupal\Core\EntityCode
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
$values = $form_state->getValues();
if ($this->entity instanceof EntityWithPluginCollectionInterface) {
// Do not manually update values represented by plugin collections.
$values = array_diff_key($values, $this->entity
->getPluginCollections());
}
// @todo This relies on a method that only exists for config and content
// entities, in a different way. Consider moving this logic to a config
// entity specific implementation.
foreach ($values as $key => $value) {
$entity->set($key, $value);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.