[html-formfu] Template::Alloy rendering error

Carl Franks fireartist at gmail.com
Fri Sep 21 20:27:39 GMT 2007


On 21/09/2007, Brian Cassidy <brian.cassidy at nald.ca> wrote:
> Hey All,
>
> I'm trying to speed up my form rendering -- I have a page with about
> 1200 checkbox + label pairs that I'm trying to display and it's taking
> about 15 seconds with TT2 before the page shows up.

Have you timed it server side? I wouldn't be surprised if at least
half of that is browser-rendering time.
I've tried a quick script that prints a form with 1200 checkboxes, and
it typically takes about 4.2 seconds with TT, and 4.8 seconds with
Template::Alloy.
I would hope most servers have more cpu and ram than the old laptop I'm running.

> I thought I might try Template::Allow to see if it improves anything.
> However, if i set
>
> Controller::HTML::FormFu:
>    constructor:
>      render_class_args:
>        TEMPLATE_ALLOY: 1
>
> in my app config and try to view a form, i get the following error:
>
> Couldn't render template "undef error - undef error - Can't locate
> object method "force_error_message" via package
> "HTML::FormFu::Render::Form" at
> /usr/local/share/perl/5.8.8/Template/Alloy.pm line 578.
> "

I'm guessing your template is calling form.render.force_error_message ?
HTML::FormFu::Render::Form doesn't actually have a
force_error_mesage() method, so it needs to fallback to the hash-key.

In your Template/Alloy.pm at the quoted line number, add a "warn $@"
immediately before the line that reads:
die $@ if ref $@ || $@ !~ /Can\'t locate object method "\Q$name\E" via
package "\Q$class\E"/;

That should reveal what's going wrong.
$@ should contain the "Can't locate..." string, so it knows to
fallback to trying a hash-key value.

> Maybe there's a better way to render such a massive amount of data?

1200 checkboxes does sound a lot!
Just for that element, you could try inlining some of the included
templates, and set the element's filename() to the new file.

Carl



More information about the HTML-FormFu mailing list