[html-formfu] (catalyst + formfu + TT + mason) undef error - Can't use string ("") as a HASH ref while...

Carl Franks fireartist at gmail.com
Fri Jan 18 16:15:24 GMT 2008


On 18/01/2008, Benjamin Bellee <bellee at webit.de> wrote:
> hello,
>
> im getting this error:
>
> snip-------------------------------
> undef error - Can't use string ("") as a HASH ref while "strict refs" in
> use at /usr/local/share/perl/5.8.8/HTML/FormFu/Util.pm line 302. Stack:
> [/usr/local/share/perl/5.8.8/HTML/FormFu/Util.pm:302]
> [/home/twist/ws/liekwoe-catalyst-2/root/formfu/start_form:1]
> [/usr/local/lib/perl/5.8.8/Template/Document.pm:155]
> [/usr/local/lib/perl/5.8.8/Template/Context.pm:345]
> [/usr/local/lib/perl/5.8.8/Template/Context.pm:407]
> [/home/twist/ws/liekwoe-catalyst-2/root/formfu/form:2]
> [/usr/local/lib/perl/5.8.8/Template/Document.pm:155]
> [/usr/local/lib/perl/5.8.8/Template/Context.pm:345]
> [/usr/local/lib/perl/5.8.8/Template/Service.pm:94]
> [/usr/local/lib/perl/5.8.8/Template.pm:68]
> [/usr/local/share/perl/5.8.8/HTML/FormFu/base.pm:81]
> [/usr/local/share/perl/5.8.8/HTML/FormFu/base.pm:20]
> [/usr/local/share/perl/5.8.8/HTML/FormFu.pm:35]
> [/usr/local/share/perl/5.8.8/HTML/Mason/Request.pm:1175]
> [/home/twist/ws/liekwoe-catalyst-2/root/review/view:10]
> snip---------------------------
>
> while trying to get formfu working with TT.
> i'm using mason for the general HTML-templates and
> (try to) use TT for the FormFu layout.
>
> i think i've followed the docu correctly, here is what i've done:
>
> 1. added this to the main project YAML:
>
> 'Controller::HTML::FormFu':
>   constructor:
>    render_method: tt
>
> 2. Im using Catalyst::Controller::HTML::FormFu,
> so in the controller im writing:
>
> sub view : Chained('review') PathPart() CaptureArgs() : FormConfig
> {
>     my ( $self, $c) = @_;
>     my $form : Stash;
>     ....
> ....
> }
>
> 3. in my mason template im using:
>
> <%args>
>     $form
>     .....
> </%args>
>
> .....
>
>     <% $form %>
>
> ......
>
> 4. i've done
>
>  script/myapp_create.pl HTML::FormFu
>
>
>
>
> anything i've missed or forgot or doing wrong?

Everything looks ok (although I'm not familiar with mason templates).

Have you checked whether the form config you're using loads and
renders ok without the catalyst / mason overhead?
Try both:
    perl -MHTML::FormFu -le 'print
HTML::FormFu->new->load_config_file(q{path/to/config.yml})'
and the same with the environment variable HTML_FORMFU_RENDER_METHOD = 'tt'

The fact that it's dying trying to build the tag attributes in the
start_form template suggests there's something major wrong, such as
the data structures not being built properly.

You can get a dump of the data at that point by editing the file
HTML/FormFu/base.pm, and in the 'tt' sub, change these lines:
    my %vars = (
        self          => $args->{render_data},
        process_attrs => \&process_attrs,
    );

to this:
    use Data::Dumper;
    my %vars = (
        self          => $args->{render_data},
        process_attrs => \&process_attrs,
        _dumper => sub { warn Data::Dumper::Dumper( \@_ ) },
    );

And then at the top of the start_form template, add:
    [% _dumper( self ) %]

What version of HTML::FormFu are you using?
If you upgraded from an earlier version, did you update the core template files?

Cheers,
Carl



More information about the HTML-FormFu mailing list