powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 415 forks source link

how to use type List with NestedModel without modal window? #470

Closed comalex closed 8 years ago

comalex commented 9 years ago

hi, i want use list with nested model like it Image. How can i do it? thank

fonji commented 9 years ago

There's a pull request #453 documenting it. Here's a copy-paste of the solution:

// Use standard 'Object' editor for list items.
Form.editors.List.Object = Form.editors.Object;

// Use standard 'NestedModel' editor for list items.
Form.editors.List.NestedModel = Form.editors.NestedModel;
comalex commented 9 years ago

thank, but how i can change atribute name? for example first:

<input name="article-0">
<input name="id-0">

another:

<input name="article-1">
<input name="id-1">

?

fonji commented 9 years ago

I'm not sure what you're trying to do. You either want two lists, or one list with another editor with two fields.

comalex commented 9 years ago

i want to do inline-formset. To save the result on a server i need that all input have different name. If i click button "add" generates the same name...

fonji commented 9 years ago

Can't you manage arrays on the server? I mean, if you receive something like this:

{
  things: [
    {
      article: 'article-1-value',
      id: 'article-1-id'
    },
    {
      article: 'article-2-value',
      id: 'article-2-id'
    },
  ]
}

It seems cleaner than guessing input names.

comalex commented 9 years ago

yes, it sounds good, thank

glenpike commented 8 years ago

Closing as question appears to have been answered.