For our new project, we have started using Zend Framework 2 and Dojo 1.8. ZF2 has a completely rewritten form module, which now features the new CollectionElement for one-to-many relationships. Regarding UI I find, that dgrid fits best for such relationships (using the editor column plugin), so I started extending FormCollection, FormRow and FormElement view helpers, so they can render the desired dgrid. Everything was fine until I realized, that I cannot set per-row input names for the dgrid widgets.
I started with the ZF2 documentation rearding form collections. One can see, that collection input elements have array-like names like
order[products][0][name]
order[products][0][price]
order[products][1][name]
order[products][1][price]
On the other hand, dgrid's configuration is column based, so I can have a column definition like
editor({
field: "_dojo_textbox_505ee3a390d705_26717315",
label: "Name",
editorArgs: {
name: "order[products][{index}][name]",
}
}, TextBox)
This column definition will define set the same widget name for all rows, which does not work with the ZF2 collection data format requirement.
What I also tried is naming the column like this:
order[products][]
which works, but does not allow the desired format
order[products][][name]
Maybe there is a way to post the data like this:
order[products][name][]
and have it converted afterwards, but the solution doesn't looks right. Beside this I am trying to produce reusable code and want to avoid per-form data modifications.
Since I am trying very hard to avoid onSubmit/onClick event handling for data conversion, there are 2 possible solutions: 1. Make dgrid able to set per-row widget names 2. Make ZF2 form understand some other-than-standard POST format for collections
Unfortunately I ran out of ideas, how either of those solutions can be done, so I will be most thankful, if you can give me a hand with this!
Since this is somewhat related with my current question, I will place it here as a side question: What other than this UI solution do you use for your one-to-many form interfaces with dojo?