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

duplicate collection index if you delete an item and then add a new one #1106

Open
ychadwick opened this issue Aug 26, 2015 · 3 comments · May be fixed by #1241
Open

duplicate collection index if you delete an item and then add a new one #1106

ychadwick opened this issue Aug 26, 2015 · 3 comments · May be fixed by #1241

Comments

@ychadwick
Copy link
Contributor

When using the collection widget, with the mopaboostrap-collection.js you can end up with duplicate indexes which results in either errors when processing the form values, or data going missing.

Easy to reproduce:

  1. Start with a collection of 3 items
  2. Delete the first item
  3. Add a new item

You will see that the second and newly created third item will have the same index of [2].

They only way to use the widget in it's current form is to add all the new items you need, and then delete the ones you don't just before saving
screen shot 2015-08-26 at 14 50 13

@ychadwick
Copy link
Contributor Author

One solution would be the ability to set the initial_size variable via a data attribute on the widget in php

....
$builder->add(
                'nice_email_collection_with_options',
                'collection',
                array(
                    'type' => 'email',
                    'attr' => array('data-collection-initial-size' => 3),
....

then using it in the collection plugin definition

$.fn.collection = function (option) {
        var coll_args = arguments;

...

    if($(collection_id).data('collection-initial-size')){
            options.initial_size = $(collection_id).data('collection-initial-size');
    }

@metalmini
Copy link

Why is this still a problem? Are there any workarounds for this?

@isometriks
Copy link
Collaborator

I assume because nobody has fixed it yet

MisatoTremor added a commit to MisatoTremor/MopaBootstrapBundle that referenced this issue Jan 22, 2019
@MisatoTremor MisatoTremor linked a pull request Jan 22, 2019 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants