How to deal with dynamic sizes of control lists in Play 2.0?

I really like the Play 2.0 form matching system, but I have a question about how to implement forms with lists of similar controls.

In Rails, if I had a list of form parameters like

foo[]=3, bar[]=4, foo[]=2, bar[]=5

      

I would end up with a structure that looks like

[{:foo => 3, :bar => 4}, {:foo => 2, :bar => 5}]. 

      

In Play, I can do this by specifying explicit indices, eg.

foo[0]=3, foo[1]=4, etc.

      

But for forms where I can dynamically add and remove records on the page before submitting the form to the server, it requires a little accounting information to make sure the indexes are correct. Does Play support something like the Rails approach where I can add new foo / bar pairs to my forms and each one appears as a separate entry in the array?

+3


source to share


1 answer


The problem you have comes from RepeatedMapping where the function indexes

in the companion just collects the ints, sorts them and finally differs ...

What can be done is to update the map so that continuous indices ...



So the only way, at least I can see, is to create the same type of rebind that will handle it ... But I think it could be added as a functionality improvement?

+1


source







All Articles