-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PropertyAccessor::getReadAccessInfo()
throws exception that could be more specific
#46867
Comments
Adding this to the PropertyAccess component isn't something that we can do as the component can be and is used without Symfony forms. However, the place where we leverage the property accessor in the Form component is the |
@xabbuh great! I'll try to open a pull request tonight modifying |
No luck -- I had some issues getting PHP 8.1 on my mac last night, which prevented me from installing dependencies and running tests. I'll try again sometime in the coming weeks. |
If you like you can edit the files via Github UI and create a PR, tests are then executed automatically for you on CI |
PropertyAccessor::getReadAccessInfo()
throws exception that could be more specific
Adds more helpful exceptions when properties cannot be accessed/set using forms. Closes symfony/symfony#46867.
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
Dear bot, please don't close this issue yet. |
…ns (patrickmaynard) This PR was squashed before being merged into the 7.1 branch. Discussion ---------- 46867 - add more helpful property path accessor exceptions | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #46867 | License | MIT | Doc PR | none Dear reviewers, This small modification adds more helpful exceptions when properties cannot be accessed/set using forms. Only one file was modified, so it should be relatively easy to review. Please feel free to leave a comment if you have any questions about what I'm doing here, and thanks for your work as a reviewer on an open-source project! All the best, Patrick Commits ------- 8d87a67 46867 - add more helpful property path accessor exceptions
…ns (patrickmaynard) This PR was squashed before being merged into the 7.1 branch. Discussion ---------- 46867 - add more helpful property path accessor exceptions | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | symfony/symfony#46867 | License | MIT | Doc PR | none Dear reviewers, This small modification adds more helpful exceptions when properties cannot be accessed/set using forms. Only one file was modified, so it should be relatively easy to review. Please feel free to leave a comment if you have any questions about what I'm doing here, and thanks for your work as a reviewer on an open-source project! All the best, Patrick Commits ------- 8d87a672a2 46867 - add more helpful property path accessor exceptions
Symfony version(s) affected
5,6, possibly others
Description
Currently, if a form field does not have an equivalent setter or adder and does not use the
['mapped' => false]
option, we get aNoSuchPropertyException
that complains about a lack of setters or adders when submitting the form.(This is
Symfony\Component\PropertyAccess\PropertyAccessor::getReadAccessInfo()
, in the method's finalelse
branch.)That's fine, I guess, but it can be a little bit confusing. Would it be safe for me to open a pull request adding a reference to
['mapped' => false]
as a possible fix in the text of the exception? Or is this method used in non-form contexts?How to reproduce
Create a form field in a form type that doesn't have a setter or adder associated with it in the equivalent Doctrine entity, and don't pass any options to the field. Then submit the form. You should get a nice NoSuchPropertyException talking about the missing methods, but it won't mention anything about how to solve the issue if you don't want to add those methods.
Possible Solution
I'm thinking about opening a pull request to change this part of
Symfony\Component\PropertyAccess\PropertyAccessor::getReadAccessInfo()
...... but I first need to know that it's safe for me to do so without accidentally adding misleading instructions about form options to contexts that don't involve forms.
Please comment!
Additional Context
No response
The text was updated successfully, but these errors were encountered: