[html-formfu] Repeatable constraints

Carl Franks fireartist at gmail.com
Tue Dec 8 14:09:36 GMT 2009


Hi Doug,

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:

Ok, I've figured out a fix for this, though at the moment it doesn't
work for any constraints that override the process() method - I think
these are just constraints that handle multiple fields at once.
Once I've gone through each of these, I'll know if my current fix is
appropriate to apply.

> Also, I'm having a hard time figuring out how to make a constraint
> requiring that at least one of the repeated fields is non-empty,
> without making all of them be required.  Any ideas?

Not yet, but I'll have a think about it. I suspect it'll require a new
constraint especially for repeatable blocks.

Carl



More information about the HTML-FormFu mailing list