FormBundle
FormBundle copied to clipboard
Fatal error due to deprecation of Symfony\Component\Form\Util\PropertyPath
I have this fatal error after symfony vendor upgrade, trying to use "entity_id" :
FatalErrorException: Error: Class 'Symfony\Component\Form\Util\PropertyPath' not found in vendor/gregwar/form-bundle/Gregwar/FormBundle/DataTransformer/EntityToIdTransformer.php line 85
PropertyPath class is apparently deprecated.
Just have to replace : $propertyPath = new PropertyPath($this->property); return $propertyPath->getValue($data);
By : $propertyAccessor = new PropertyAccessor(); return $propertyAccessor->getValue($data, $this->property);
And change the use statement : use Symfony\Component\PropertyAccess\PropertyAccessor;
Is this compatible with older sf versions?
2013/10/7 isabellebruchet [email protected]
Just have to replace : $propertyPath = new PropertyPath($this->property); return $propertyPath->getValue($data);
By : $propertyAccessor = new PropertyAccessor(); return $propertyAccessor->getValue($data, $this->property);
And change the use statement : use Symfony\Component\PropertyAccess\PropertyAccessor;
— Reply to this email directly or view it on GitHubhttps://github.com/Gregwar/FormBundle/issues/16#issuecomment-25808681 .
Grégoire Passault
Apparently these new files exist since version 2.2, however, the code I posted above works, but it is not exactly the right way. PropertyAccessor should not be accessed directly but via PropertyAccess.
Right way : https://github.com/isabellebruchet/FormBundle/commit/d4ab0260c2e94b9ba2de03dd20f7e6e330b8dc85
Is this bug still occurs? Imho this issue can be closed.
@isabellebruchet, @Gregwar