[cgiapp] Re: ValidateRM and dynamic content

John Spooner jspooner at liaison-intl.com
Mon Mar 10 13:56:38 EDT 2008


Sorry for the late response.  I was up against a deadline and had to
switch tactics, but wanted to post a follow up for at least archive
purposes.

The project ultimately produced surveys each with content that could be
classified into different form types (checkbox, radio, text, etc) and
some more complex forms (ex. Some checkbox and radio sections require
accompanying text (check "0ther" or "Please describe...")).  In any
event all questions belong to one variation of a form element.  I
created one template that contained all of the standard form info
(headers/footers, etc) and a loop that examines each question on that
template (question info is stored in a database) and displays the proper
form element.  Everything worked great until validation.  The problem
seems to lie in the fact that the name of the form element was
dynamically named.

Example:
	<input type="text" name="<TMPL_VAR foo>" maxlength....>

This works great for the original display of the template, but if errors
are detected there doesn't seem to be a way (that I can think of at
least) to template the error message.  My error messages have the prefix
'err' so to template error message I am left with:

<TMPL_IF err_<TMPL_VAR foo>>
	err_<TMPL_VAR foo>
</TMPL_IF>

The TMPL_IF line is not legal H::T syntax, so I tried the line without
TMPL_IF statements.  No matter what I did the error message would not
display.

I ended up creating one template for each survey section each with the
questions for each section explicitly defined (mostly static) in order
to get the project out the door.  I'd like to revisit the idea of one
dynamic template for this application because it would make annual
maintenance simple and adding new surveys trivial.

After I asked the list I did try creating a bit of HTML::Template code
separate from the dynamic template and then tried to include it back in.
The closest I came to making it work is error sections were created and
physically included in the template so that the TMPL_IF error code
posted above would be part of the page source of the HTML page.


-----Original Message-----
From: cgiapp-bounces at lists.openlib.org
[mailto:cgiapp-bounces at lists.openlib.org] On Behalf Of Mark Stosberg
Sent: Saturday, March 08, 2008 4:32 PM
To: cgiapp at lists.openlib.org
Subject: [cgiapp] Re: ValidateRM and dynamic content

>
> I am using HTML::Template and CGI::Application::Plugin::ValidateRM.
> Page content is generated dynamically which works fine until a
> validation error occurs.  Unfortunately <err_<TMPL_VAR field_name>> is
> not valid H::T.

Could you provide a more complete example? I have been using ValidateRM
and H::T with complex websites for years and haven't gotten stuck here.
I suspect there's another way to accomplish your goal while still using
sing these tools.

     Mark

-- 
http://mark.stosberg.com/



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################




More information about the cgiapp mailing list