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

Wrong initial collection index #858

Closed
ro0NL opened this issue May 12, 2014 · 7 comments
Closed

Wrong initial collection index #858

ro0NL opened this issue May 12, 2014 · 7 comments

Comments

@ro0NL
Copy link

ro0NL commented May 12, 2014

Hi,

Im using the bootstrap collection JS asset for a symfony collection form field (which is mapped with a doctrine collection).

The collection is embedded with zero initial elements. When adding an element (the first) it gets index 1. The initial index in the doctrine collection is 0, this way validation errors etc. are not displayed at the correct field but at the 2nd collection field (as that one has index 1) or on top of the form without a 2nd collection field.

When I debug the JS forcing to start index 0 everything works as expected. I changed:
this.options.index[this.options.collection_id] = this.options.initial_size;
to
this.options.index[this.options.collection_id] = this.options.initial_size - 1;

Can you have a look at this?

@wolfwolker
Copy link

Same problem here.
I supose that you are using 3.0-beta3.
To fix the bug change the line 108 of mopabootstrap-collection.js by this
options.initial_size = $this.parents(collection_id).find('.collection-items').children().length;

@phiamo
Copy link
Owner

phiamo commented Jun 3, 2014

could you create a pr for this please

@phiamo
Copy link
Owner

phiamo commented Oct 4, 2014

@wolfwolker
cant find the line in the current js.
can you please create a PR or update the line number so i can merge the change.

@aferrandini
Copy link
Contributor

ping @phiamo @ro0NL @wolfwolker

@ro0NL could you please test your code with the sample in #977 ?

@phiamo
Copy link
Owner

phiamo commented Jan 12, 2015

@aferrandini @ro0NL @wolfwolker is there still anything to do here?

@wolfwolker
Copy link

Seems fixed in beta4

@phiamo
Copy link
Owner

phiamo commented Jan 12, 2015

So i close this

@phiamo phiamo closed this as completed Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants