[html-formfu] Repeatable constraints

Carl Franks fireartist at gmail.com
Tue Dec 8 14:39:02 GMT 2009


2009/12/7 Doug Orleans <dougorleans at gmail.com>:
> I'm having more woes with Repeatable and increment_field_names = 0,
> this time with constraints:
>
> use HTML::FormFu;
>
> my $form = HTML::FormFu->new;
> $form->elements({ type => 'Repeatable', increment_field_names => 0,
>                  elements => [ { name => 'quantity',
>                                  constraint => 'Number' } ] });
>
> my $rep = $form->get_element;
> $rep->repeat(2);
>
> $form->process( { quantity => [ 23, 'foobar' ] } );
> print $form->render;
>
> This puts an error message on both inputs, not just the second one:

This is now fixed as of svn r1636.

Currently, constraints with an others() method don't work within a
Repeatable block - these are:
AllOrNone, DependOn, Equal, MinMaxFields, reCAPTCHA.
Also, the CallbackOnce constraint won't work within a Repeatable
block, as it wouldn't make much sense.

Note that increment_field_names(0) will cause $form->has_errors($name)
to not work as usual - it will only return true if all fields sharing
that name have no errors.
$form->valid() will also have wonky behaviour.

Cheers,
Carl



More information about the HTML-FormFu mailing list