Collection add generates invalid new name / keys when using subcollection
joschi127 opened this issue · 2 comments
First of all: thanks a lot for the awesome Bootstrap forms integration for Symfony. I started implementing the same thing, but much simpler, myself and then came across your bundle and I like it very much and it saved me a lot of time.
One problem tough when using collections:
As far as I can see there is a bug in bc-bootstrap-collection.js.
I can also reproduce it on the playground page: http://bootstrap.braincrafted.com/playground/forms.html
Steps to reproduce:
- use 2 levels of collection (a collection with a subcollection)
- remove all entries or start with an empty collection
- add entry 1
- add sub entry 1.1
- add entry 2
- add sub entry 2.1
=> entry 1 will have key [0] and entry 1.1 will have the keys [0] [0] - which is correct
=> entry 2 will have key [2] but entry 2.1 will have the keys [1] [1] - I think entry 2 should have the key [1] instead of [2]
Thanks!
PS:
I think the fix is to change line 37 of bc-bootstrap-collection.js:
Current version:
count = list.find('li').size()
Fixed version:
count = list.find('> li').size()
Am I right? At least this fixes the bug for me.
This should be fixed in #224.