[html-formfu] Repeatable elements, number of empty rows on a "create" form.

Carl Franks fireartist at gmail.com
Tue Mar 2 09:09:02 GMT 2010


On 1 March 2010 18:56, Brian Cassidy <brian.cassidy at gmail.com> wrote:
> On Mon, Mar 1, 2010 at 2:52 PM, Carl Franks <fireartist at gmail.com> wrote:
>>
>> I think you'll also need to set 'new_rows_max'.
>
> Adding "new_rows_max: 3" shows no change in the rendered form.

Ah, you didn't say at what stage the problem was ;)

If you're calling $form->model->default_values()
it should automatically expand the repeatable block.

If you're not, you'll need to do something like:

if ( ! $form->submitted ) {
    $form->get_all_element({ type => 'Repeatable' })->repeat(3);
    $form->get_all_element('count')->default(3);
    $form->process;
}

Your config should also define a hidden field - which in this example
is called 'count'
and set this on the Repeatable block
    counter_name: count

Carl



More information about the HTML-FormFu mailing list