From 1f22d3a56491c86860d323d5e6439ea5640d8034 Mon Sep 17 00:00:00 2001 From: Peter Rehm Date: Tue, 28 Jan 2014 10:33:47 +0100 Subject: [PATCH] [Form] Update DateTime objects only if the actual value has changed --- .../Form/Extension/Core/DataMapper/PropertyPathMapper.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php b/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php index d5942f2a55..d07f3f15e6 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php +++ b/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php @@ -81,6 +81,13 @@ class PropertyPathMapper implements DataMapperInterface // Write-back is disabled if the form is not synchronized (transformation failed), // if the form was not submitted and if the form is disabled (modification not allowed) if (null !== $propertyPath && $config->getMapped() && $form->isSubmitted() && $form->isSynchronized() && !$form->isDisabled()) { + + // If the field is of type DateTime and the data is the same skip the update to + // keep the original object hash + if ($form->getData() instanceof \DateTime && $form->getData() == $this->propertyAccessor->getValue($data, $propertyPath)) { + continue; + } + // If the data is identical to the value in $data, we are // dealing with a reference if (!is_object($data) || !$config->getByReference() || $form->getData() !== $this->propertyAccessor->getValue($data, $propertyPath)) {