backbone-forms
backbone-forms copied to clipboard
idPrefix is always `undefined_`
render
method of Form.editors.NestedModel
defined this.nestedForm
as follows:
render: function() {
//Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form
var NestedForm = this.form.constructor;
...
//Wrap the data in a model if it isn't already a model instance
var modelInstance = (data.constructor === nestedModel) ? data : new nestedModel(data);
this.nestedForm = new NestedForm({
model: modelInstance,
idPrefix: this.id + '_',
fieldTemplate: 'nestedField'
});
Thus, idPrefix
attribute for NestedForm
options hash was always undefined_
.
I changed the line idPrefix: this.id + ' '
to idPrefix: modelInstance.cid
in order to have unique field ids.
I also built for distribution.
I think it is now correct. If it's not, please feel free to reject my pull request: you won't hurt my feelings :)
I also changed version number and built again for distribution. I did it because I need to consume my fork with bower. Hope it helps.