-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Typo in Exception in Symfony\Component\Form\Form #22103
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
Comments
This is not a mistake, the message is right and the exception is justified, cf the doc of form events (http://symfony.com/doc/current/form/events.html) and especially this warning :
|
Ok, makes sense. but maybe it should be clarified which setData is meant in the first place. P.S. I got this when I called |
Ok I see exactly the problem and you are right, the message is not logic for the DX. That happens when no data was set when the form is built, and then you use When you try to get the data directly from the form, as it was not set, it tries to set the default data with a We can throw another exception with a better message. |
That also mean that if no data was already set for the form, in a |
well, getting the data from the form before it is set in it does not make any sense anyway. It is not there yet. |
I agree but the problem is that if you try to do it, you get a misleading / unrelated message. |
@javiereguiluz I will work on improving this. |
…in a PRE_SET_DATA listener and the data has not already been set (fancyweb) This PR was merged into the 2.7 branch. Discussion ---------- [Form] Improve the exceptions when trying to get the data in a PRE_SET_DATA listener and the data has not already been set | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22103 | License | MIT | Doc PR | - Commits ------- ef39b70 [Form] Improve the exceptions when trying to get the data in a PRE_SET_DATA listener and the data has not already been set
File https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php
throw new RuntimeException('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.');
I believe here is a typo, in first case there should be
getData
instead of setData.The text was updated successfully, but these errors were encountered: