[html-formfu] Constraints on repeatable fields

Yves Räber yraber at mailup.net
Tue Aug 4 07:35:08 GMT 2009


Hi,

I'm trying to add a required constraint to repeatable fields, but FormFu seems to simply ignore the constraints.

Here is the simplest example I could think of :

yml:
---
elements:
  - type: Repeatable
    name: my_rep
    elements:
            
      - name: foo
        label: Foo
        constraints:
          - type: Required
      
  - type: Submit
    name: submit

catalyst controller:

sub test :Local :FormConfig {
    my ( $self, $c ) = @_;

   my $form  = $c->stash->{form};
   $form->get_all_element({ type => 'Repeatable' })->repeat(2);

}

Here is the constraint debug messages when I send the form without anything in both fields :

HTML::FormFu::_constrain_input()
FIELD NAME: 'foo_1'
CONSTRAINT TYPE: 'Required'

HTML::FormFu::Constraint::process()
CONSTRAINT RETURN VALUE: '0'
$@: ''

HTML::FormFu::_constrain_input()
ERRORS: [
          bless( {}, 'HTML::FormFu::Exception::Constraint' )
        ];
$@: ''

I think I'm missing something here, any help would be very welcome.

Thank you.



More information about the HTML-FormFu mailing list