[html-formfu] HTML::FormFu::Element::Repeatable questions

Will Hawes wdhawes at gmail.com
Tue Jul 29 10:34:45 BST 2008

The Repeatable docs state "repeat is automatically called during
$form->process, to ensure the initial child elements are correctly

So if you want more than one repetition, you have to call repeat()
after process(), otherwise process() reverts everything back to just
the one:

  - type: Repeatable
    id: repeater
      - type: Text
        name: foo

my $repeater = $form->get_element({ name => 'repeater' });

# 5 repetitions

# repetitions overwritten, now just one

# 5 repetitions again

This is problematical if you want to modify (e.g. rename) some of the
repeated fields prior to calling process(), because they will be
removed when process() calls repeat(1). In my case I want to append a
database primary key value to the name of each repeated field, but the
same applies to any other modification.

I think it might be better if process() called repeat(1) only if
repeat() had not been called already, so you could call repeat() and
modify the generated elements prior to calling process(). I've tested
this briefly and it doesn't appear to have any unwanted side effects.

I'm happy to patch it if others are in agreement.


More information about the HTML-FormFu mailing list