diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index 301b5ae..b82d283 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -291,11 +291,18 @@ public function buildEntity(array $form, FormStateInterface $form_state) { * The current state of the form. */ protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { + $keys_to_skip = []; + if ($this->entity instanceof EntityWithPluginCollectionInterface) { + // Do not manually update values represented by plugin collections. + $keys_to_skip += array_keys($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 ($form_state->getValues() as $key => $value) { - $entity->set($key, $value); + if (!in_array($key, $keys_to_skip)) { + $entity->set($key, $value); + } } } diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index 4edd31c..9c4887c 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -7,7 +7,6 @@ namespace Drupal\image\Form; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; @@ -286,16 +285,4 @@ protected function updateEffectWeights(array $effects) { } } - /** - * {@inheritdoc} - */ - protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { - foreach ($form_state->getValues() as $key => $value) { - // Do not copy effects here, see self::updateEffectWeights(). - if ($key != 'effects') { - $entity->set($key, $value); - } - } - } - }