FAQ
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.

Search Discussions

  • Mario Minati at Aug 4, 2009 at 6:19 pm
    Hi Yves,

    did you call process?


    Greets,

    Mario Minati


    Yves R?ber schrieb:
    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.

    _______________________________________________
    HTML-FormFu mailing list
    HTML-FormFu@lists.scsys.co.uk
    http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
  • Yves Räber at Aug 5, 2009 at 7:39 am
    Wow ... that was easy :)

    In my case, 'Catalyst::Controller::HTML::FormFu' take care of running process, but it seems it's called BEFORE the repeat is executed.

    Adding a $form->process right after my repeat works fine.

    Thank you.

    ----- Original Message -----
    From: "Mario Minati" <mario.minati@googlemail.com>
    To: "HTML Form Creation, Rendering and Validation Framework" <html-formfu@lists.scsys.co.uk>
    Sent: Tuesday, August 4, 2009 8:19:18 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
    Subject: Re: [html-formfu] Constraints on repeatable fields

    Hi Yves,

    did you call process?


    Greets,

    Mario Minati


    Yves R?ber schrieb:
    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.

    _______________________________________________
    HTML-FormFu mailing list
    HTML-FormFu@lists.scsys.co.uk
    http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

    _______________________________________________
    HTML-FormFu mailing list
    HTML-FormFu@lists.scsys.co.uk
    http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
  • Lance A. Brown at Aug 5, 2009 at 2:25 pm

    Yves R?ber wrote:
    Wow ... that was easy :)

    In my case, 'Catalyst::Controller::HTML::FormFu' take care of running process, but it seems it's called BEFORE the repeat is executed.

    Adding a $form->process right after my repeat works fine.
    Correct. If you do anything to the form in a C::C::HTML::FormFu based
    controller, you need to run $form->process again because you've changed
    the form. :-)

    --[Lance]

    --
    GPG Fingerprint: 409B A409 A38D 92BF 15D9 6EEE 9A82 F2AC 69AC 07B9
    CACert.org Assurer

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouphtml-formfu @
categoriesperl, catalyst
postedAug 4, '09 at 7:35a
activeAug 5, '09 at 2:25p
posts4
users3
websitemetacpan.org...

People

Translate

site design / logo © 2022 Grokbase