[html-formfu] Nested forms using has_many relationships from DBIC

Henning Kulander hennikul at linpro.no
Fri Dec 14 15:49:21 GMT 2007


On 2007-12-13 21:13, Carl Franks <fireartist at gmail.com> wrote:

>>Now I get a form with all related Accesipranges objects. But when I
>>save
>>the form, only the first one is processed. That is, if I update the
>>second object, validators and condition checks are not run on that
>>object, it is not saved either. If I update the first object, it is
>>validated and saved to the database using an UPDATE. Creating new
>>objects works aswell, but only if the empty object is first.. :)
>
>I've just realised it's not documented yet, but has_many and
>many_to_many rels require an extra hidden field, which keeps count of
>the number of related rows.
>You don't need to set this field's value, that's taken care of
>automatically.
>This is also used to call $repeatable->repeat($count) during
>$form->process(), which ensures the constraints, etc. are run
>correctly.
>
>This hidden field needs to be outside the Repeatable block, attached
>to the same parent as the block.
>
>---
>elements:
>- type: Hidden
>name: count
>- type: Repeatable
>increment_field_names: 1
>counter_name: count
>- elements
>...

This made all the difference.. :) It seems to work now.

Thanks!


Regards,
Henning Kulander




More information about the HTML-FormFu mailing list