Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39b4abe

Browse files
committed
Be specific about ignored AccessExceptions when mapping to form
1 parent 6c3aaf2 commit 39b4abe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Form\DataMapperInterface;
1515
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1616
use Symfony\Component\PropertyAccess\Exception\AccessException;
17+
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
1718
use Symfony\Component\PropertyAccess\PropertyAccess;
1819
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1920

@@ -51,6 +52,12 @@ public function mapDataToForms($data, $forms)
5152
$form->setData($this->propertyAccessor->getValue($data, $propertyPath));
5253
} catch (AccessException $e) {
5354
// Skip unitialized properties on $data
55+
if (!$e instanceof UninitializedPropertyException
56+
// For versions without UninitializedPropertyException check the exception message
57+
&& (class_exists(UninitializedPropertyException::class) || false === strpos($e->getMessage(), 'You should initialize it'))
58+
) {
59+
throw $e;
60+
}
5461
}
5562
} else {
5663
$form->setData($config->getData());

0 commit comments

Comments
 (0)