Skip to content
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

Deletion of item in BootstrapCollectionType deletes wrong item. #49

Open
matejvelikonja opened this issue Oct 29, 2015 · 0 comments
Open

Comments

@matejvelikonja
Copy link
Contributor

I encountered an issue while deleting item from BootstrapCollectionType.
When you delete one of the items using forms, the last item is always deleted instead. I've already debugged a little bit a found out that the problem is in the ReorderCollectionSubscriber.
This subscribers resets keys of the array and that's why the last item is always deleted.

For example:
I have an array:

[
    0 => "zero",
    1 => "one",
    2 => "two",
]

By using forms I delete first array element and all I have now is:

[
    1 => "one",
    2 => "two",
]

When this array is passed to the ReorderCollectionSubscriber in changes array to:

[
    0 => "one",
    1 => "two",
]

And this array is at some point passed to doctrine, doctrine does the calculation and from the array it assumes that the array element with key 2 was deleted and so the last entry is deleted from the database.

Maybe I forgot to set something but I don't know why and I don't even know why this ReorderCollectionSubscriber is doing this at all.

In my opinion this is quite a serious bug and should be addresses as soon as possible. For the current project I just commented out the adding of ReorderCollectionSubscriber to BootstrapCollectionType and the problem is gone and as far as I see everything is working normally. But not sure if this is the proper solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant