-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Keep selected choices when extra choices have been submitted #9738
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
@trsteel88 How does your controller look like? Are other form fields filled out? I’m a little busy at the moment but I can review the issue on Saturday. |
@trsteel88 I’m trying to reproduce it with a fresh 2.3.7 (or which version are you on?) project. What do you refer to by "all the valid options I have chosen"? Do you mean options on the same entity field? So it is multiple true? Or other fields in the form? Other fields in the form are selected correctly in my case (see https://github.com/hacfi/symfony9738). |
If you refer to the other selected options in the same field, here is what happens: symfony/src/Symfony/Component/Form/Form.php Line 634 in 1bc2d9f
Quick fix: Extend If this is a desired feature we can add an option to the field type. |
@trsteel88 ping |
Sorry, I missed the last few comments. I will provide an example on Monday (possibly earlier). Basically I have an expanded set of entities. If you select all of them and hit submit (after someone else deletes 1 of the entities in the set you have chosen because you loaded an older version) the entire set throws and error and none of the entities you chose are selected. I think it should reload with an error and all the entities you selected which are valid should be selected. |
I can confirm that’s happening. The reason is the following line: See #9738 (comment) for my suggested solutions. |
Oh great. I will test it out ASAP. |
Status: Reviewed |
Hey, thanks for your report! |
will be fixed by #39659 |
…s are submitted (xabbuh) This PR was merged into the 4.4 branch. Discussion ---------- [Form] keep valid submitted choices when additional choices are submitted | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #9738 | License | MIT | Doc PR | Commits ------- 85989c3 keep valid submitted choices when additional choices are submitted
I have an expanded form type. If I load the page, then someone deletes one of the entities that is in my available choices and I select/submit it I get an error. This behaviour is correct.
However, all the valid options I have chosen have no been unselected and the data reverts to the original value. Is there a way to stop this and use the values that were selected regardless of whether it is valid/invalid. Or potentially even just ignore invalid values?
The text was updated successfully, but these errors were encountered: