-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Errors Property Paths mismatch CollectionType children when removing an entry #39438
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
[Form] Errors Property Paths mismatch CollectionType children when removing an entry #39438
Conversation
Hey! I didn't know that was capable of this emotion. I really really like reviewing this PR. Well done. To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
a435596
to
dc5e0b2
Compare
@StevioStudio Sorry, your PR somehow slipped through. Thank you for taking the time to create a failing test case. That's really appreciated. 👍 I will try to look into a possible fix soon. |
As your test also asserts the entry form types of the collection type are not renamed. So after submitting we only have entry types named With the current implementation I do not see how we can actually fix this as inside the For your project I see two possible workarounds:
|
Wait, this is not only related to the model I'm using in this unit test. |
While I agree I don't see a way to fix this without introducing a new option (like proposed in #7828). So that would go into a future minor version instead of a patch release. By the way, is it really a common use case to use the |
Well, you know that I think the new option with a minor version release could be a good idea. What do you think? |
I have a feature like that on my to-do list. Though not sure when I will find the time for it. Hopefully it will make it to 5.3. |
88d307e
to
a4462c8
Compare
I came up with a new |
a4462c8
to
2cad8ee
Compare
This PR initially started as a bug fix with unit test provided to explain the issue. |
@xabbuh, @yceruto, @chalasr, @dunglas, @jderusse, @lyrixx, @sroze, @wouterj The real solution must be in the backend, because it is simply a bug and not a feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against a new opt-in feature for this but we should be careful when documenting it.
Indeed, such behavior depends on how the collection type data is mapped to the parent object.
In other words, how the adder and remover are implemented in the holder of the collection impact indexes without being able to send feedback to the collection type when going back to the view with errors.
Sadly after discussing this issue with @stof, we cannot think of another way to work around that efficiently, since the PropertyAccess does not allow to set specific indexes when calling adders and removers.
//In fact, root form should NOT contain errors but it does | ||
$this->assertCount(1, $form->getErrors(false)); | ||
|
||
//Let's do this again, but with "keep_as_list" option set to true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create another test method instead of grouping two tests in the same one please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need a rebase and to update the changelog.
Please tell us if you want to do it or if we should take over, thank you.
94bae4d
to
70e1b0e
Compare
70e1b0e
to
fff25e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make fabbot happy fixing the CS and update the Form component CHANGELOG please. Thanks
fff25e3
to
f31de2b
Compare
f31de2b
to
39587cb
Compare
Thank you @cristoforocervino. |
Description
When you remove an entry from
CollectionType
and you have errors on children, errors property paths generated byValidatorExtension
are matching final object collection indexes but do not match From children entries index/names.How to reproduce
Unit test provided.
Solution
Introduce new feature with
keep_as_list
(boolean
default tofalse
) option to reindex children on submit.