On 24/02/07, Mario Minati <[EMAIL PROTECTED]> wrote:
I have an other idea of extending the formfu. Actually It's more a need than an idea. I need forms to submit n-times the same field, e. g. I want to be able to submit telephone numbers, but don't know if it will be only one or ten. My database is that flexible that it can hold as many numbers as given. Now I would like to create an javascript-supported form which gives me in the beginning one field for a telephone number and a '+'-button which creates an additional field. This concept should not only work for one single field that can be repeated but also for a complete fieldset, so that I could submit multiple address to give an other example.
Having multiple copies of a fieldset definitely causes extra complexity. If you just had multiple copies of a telephone field, they could all have the same name, and you just make sure you handle multiple values for that parameter. Having copies of an entire fieldset means that you have to have a unique name for every field, because there's no guarantee that the input will be sent back in the same order. The way I imagine this working is something like... change id_format() to support some sort of iterator, for generating sequential id names. also let it accept a subroutine-ref for more advanced generation of id's. Add a name_format() method to provide the same capabilities for name generation. Add a duplicate() method to fieldsets and fields, which clones the element (and all its constraints, etc), generates new ids and names, and adds it to the form immediately after the existing element If it's an ajax request that only wants the markup for the new element, print $form->result->field('new-field'); otherwise, if it's a non-JS request, and you need to render the whole page again with the new element, then print $form->result; as normal. It would also be nice to get nested parameters working with formfu - which would help organise these kind of values. (nested params are rails-like "address.city" or "address[city]" style) Anyway - that's some thoughts for now - but it undoubtedly needs some details filled in. Carl _______________________________________________ Html-widget mailing list Html-widget@lists.rawmode.org http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget