[Catalyst] current profile won't fill with C::P::FormValidator::Simple::Auto

rahed raherh at gmail.com
Thu Apr 17 13:22:12 BST 2008


I use C::C::FormBuilder which lacks complex validation. I looked
around and want to use C::P::FormValidator::Simple::Auto with external
yaml files.

$c->config->{validator}->{profiles} gets filled from my profile file but
current profile ($c->validator_profile) is never filled.

This should be done in a C::P::FV::S::A forward method but true test
$c->config->{validator}{profiles}{ $action }
is never ok.

I call my run action having forms like this:

And calling $c->form->has_error within run action should throw an
error according to profile rules. Object $c->form is
FormValidator::Simple::Results object. It has only message part but
profile part is missing.

Cannot find out why this behaviour. Could someone shed some light?

sub forward {
    my $c = shift;
    my $action = $c->dispatcher->_invoke_as_path($c, @_);

    no warnings 'once';
    local $NEXT::NEXT{ $c, 'forward' };

    my $res;
    if ( my $profile = $c->config->{validator}{profiles}{ $action } ) {
        # first time validation
        if (not $c->validator_profile) {
            $c->{validator_profile} = $action;

            $res = $c->NEXT::forward(@_);
        else {
            # don't override validator stuffs when not first time validation
            local $c->{validator} = FormValidator::Simple->new;
            local $c->{validator_profile} = $action;

            $res = $c->NEXT::forward(@_);
    else {
        $res = $c->NEXT::forward(@_);



More information about the Catalyst mailing list