[html-formfu] adding constraints dynamically
Moritz Onken
onken at houseofdesign.de
Sat Aug 15 08:15:01 GMT 2009
Am 15.08.2009 um 05:47 schrieb Steve Rippl:
> Hi,
>
> I have a Catalyst app with large dynamic forms, most of which gets
> built programatically with things like
>
> ...
> my $element = $form->element( Text => $form_id );
> $element->name($form_id);
> $element->id($form_id);
> ...
> $element->add_attributes( size => $size, maxlength => $size );
> ...
> etc etc...
>
> Now, how can I add constraints in this way? $element-
> >constraints( 'Range' => ( min => $min, max => $max )
> $element->constraints( { type => 'Range', min => $min, max => $max } )
This should work.
There is also a Regex constraint:
> $element->constraints( { type => 'Regex', regex => qr/regex/ } )
You need to create a custom Constraint if you want to have an "or"
constraint.
cheers,
moritz
More information about the HTML-FormFu
mailing list