4 Feb 21:33
[FormBuilder] Dynamic fields and templates
From: Dan Axtell <daniel.axtell <at> snet.net>
Subject: [FormBuilder] Dynamic fields and templates
Newsgroups: gmane.comp.lang.perl.modules.formbuilder
Date: 2007-02-04 20:33:25 GMT
Subject: [FormBuilder] Dynamic fields and templates
Newsgroups: gmane.comp.lang.perl.modules.formbuilder
Date: 2007-02-04 20:33:25 GMT
Hi,
I'm tying to build a form where most of the fields are standard fields, laid
out via a template, but with a section where some fields may or may not be
added dynamically, depending on the record type I'm editing.
The idea was that at run time I'd do something like:
my $tmpl = HTML::Template->new( ...)
$tmpl->param('form-start' => "<tmpl_var form-start>");
$tmpl->param('form-submit' => "<tmpl_var form-submit>");
# all standard field template tags get replaced by themselves
# for FormBuilder to expand ...
$tmpl->param('dynamic-controls' => \@list_of_extra_fields);
# Now create the form object
my $form->CGI::FormBuilder->new(
fields =>\@list_of_all_fields,
template => $tmpl,
....
);
This fails because $tmpl is an HTML::Template object and doesn't have a
render() method.
Is subclassing CGI::FormBuilder::Template::HTML the only way to get something
like this to work? It seems odd that the template attribute can be an
object reference but NOT an HTML::Template reference.
_______________________________________________
(Continue reading)
RSS Feed