[Catalyst] FormValidator::Simple and FillInForm plugins refuse to work together

Alex Morozov inductor2000 at mail.ru
Wed May 17 13:45:30 CEST 2006


Hello everyone.

Did anyone face a strange problem with these two plugins?
I use Catalyst on ActivePerl 5.8.7 and the following code doesn`t render 
a page at all:

Main module:

use Catalyst qw/-Debug ConfigLoader Static::Simple
                Authentication Authentication::Store::DBIC 
Authentication::Credential::Password
                Session Session::Store::File Session::State::Cookie
                FormValidator::Simple FillInForm/;

C::Users, 'new user' sub:

sub create {
    my ($self, $c) = @_;
   
    $c->stash->{template} = 'create.tt';
    if ($c->request->method eq 'POST') {
        $c->form (
            email => [qw/NOT_BLANK EMAIL_LOOSE/],
            name => ['NOT_BLANK', ['DBIC_UNIQUE', 
$c->model('DB::Users'), 'name']],
            password => [qw/NOT_BLANK/, [qw/LENGTH 6 999/]]
        );
        if ($c->form->has_error) {
            $c->fillform;
            return;
        }
        my $email = $c->request->params->{'email'};
        my $name = $c->request->params->{'name'};
        my $password = $c->request->params->{'password'};
        my $users = $c->model('DB::Users');
        $users->create({'email' => $email, 'name' => $name, 'password' 
=> $password});
       
        $c->stash->{message} = 'User created. ';
    }
    else {
        $c->stash->{message} = 'Create a user:';
    }
}

sub end : Private {
    my ($self, $c) = @_;
    $c->forward('tour::View::tt') unless $c->res->body();
}


create.tt contents:

<html>
    <head>
        <title>Create a user</title>
    </head>
    <body>
        [% IF c.form.has_error %]
            <h3>Error!</h3>
            <ul>
            [% IF c.form.missing('name') %]
                <li>Missing name!
            [% END %]
            [% IF c.form.invalid('name') %]
                <li>Invalid name!
            [% END %]
            [% IF c.form.missing('email') %]
                <li>Missing email!
            [% END %]
            [% IF c.form.invalid('email') %]
                <li>Invalid email!
            [% END %]
            [% IF c.form.missing('password') %]
                <li>Missing password!
            [% END %]
            [% IF c.form.invalid('password') %]
                <li>Invalid password!
            [% END %]
            </ul>
        [% END %]
        [% message %]
        <form action="[% c.request.uri %]" method="post">
            Email:&nbsp;<input type=text name="email"><br>
            Name:&nbsp;<input type=text name="name"><br>
            Password:&nbsp;<input type=text name="password"><br>
            <input type=submit value="OK">
        </form>
    </body>
</html>


Well...
When I remove FillInForm dependency in main module, all works fine. But 
if FillInForm is used, I get a blank page instead of rendered template. 
Catalyst doesn`t throw an exception, but says:

Use of uninitialized value in list assignment at 
c:/Perl/site/lib/Catalyst/Engine/HTTP.pm line 228.
Use of uninitialized value in list assignment at 
c:/Perl/site/lib/Catalyst/Engine/HTTP.pm line 228.
Attempt to free unreferenced scalar: SV 0x24e0384, Perl interpreter: 
0x2241ec at c:/Perl/site/lib/SQL/Abstract/Limit.pm line 325.
Use of uninitialized value in subroutine entry at 
c:/Perl/site/lib/HTML/FillInForm.pm line 86.
Use of uninitialized value in subroutine entry at 
c:/Perl/site/lib/HTML/FillInForm.pm line 86.
Use of uninitialized value in print at 
c:/Perl/site/lib/Catalyst/Engine.pm line 577.

I searched the maillist, but didn`t find anything related. Can anybody 
help me? Thanks in advance!

--alex



More information about the Catalyst mailing list