15 Mar 17:18
Re: HTML::Template + validation = strange behavior?; Custom messages?
Marie Shvartsapel <maries <at> thecsl.org>
2005-03-15 16:18:23 GMT
2005-03-15 16:18:23 GMT
Update:
setting "keepextras" to 0 seems to fix it. But I need to use
keepextras because I'm using it for keeping "mode" parameter...(as
recommended in *Advanced Tutorial - Step 9: Multi-Screen Apps 3 @
FormBuilder.org)
*
One more question:
I'm trying to change default messages, specifically the tag that
wraps around error messages. I'm passing the hash to the FB's new()
method, as shown in the docs:
messages => {
form_invalid_opentag => '<span style="color: red">',
form_invalid_closetag => '</span>'
},
It does not have any effect for me.
Can anyone spot my mistake?
Thanks for your help,
Marie
Marie Shvartsapel wrote:
>Hello,
>
>I'm new to the FormBuilder and to this list, so please excuse me if this has
>been discussed already.
>I am trying to use HTML::Template template + validation functionality of the
>FB. I turned off JavaScript and want to use server side validation only.
>
>Let me describe the scenario in short: Form is displayed, submitted (with
>blank fields), redisplayed with error messages, submitted again (again with
>blank values). Now the fun part: All of my visible form elements get
>doubled!
>
> Am I not using FB or template correctly or this is "a feature" of FB?
>
>Ok, a little clarification - it seems to be happening when I leave the field
>blank without trying to fill it in, just submit it again , whereas this
>problem does not seem to occur when some other not-empty invalid value was
>provided and left unchanged...
>I agree that this is not very typical usage, but hey, you can overlook one
>of the values if you are working with a long form.
>I have created very simple test script to make sure nothing else gets in the
>way.
>
>You can test it for yourself here:
>http://maries.thecsl.org/cgi-bin/clearinghouse/test.pl (see code below)
>
>Another detail - I'm using "keepextras"set to 1. Not sure if this might be
>related.
>
>A little bonus question: Is my understanding correct that I have to
>explicitly include "<tmpl_var error-name1>" into my template if I want error
>messages to be displayed? Originally I thought that <tmpl_var field-name1>
>will take care of error msgs for me....
>
>Thanks in advance, I really hope to get this resolved...
>-Marie.
>
>Script code:
>#!/usr/bin/perl
>use strict;
>use warnings;
>use CGI::FormBuilder;
>my $form=CGI::FormBuilder->new(
> fields => [qw(name1 name2)],
> method => 'post',
> template => 'temp.temp',
> validate => {
> name1=>'NAME',
> name2=>'NUM'
> },
> header=>1,
> keepextras=>1,
> javascript=>0
>);
>if ($form->submitted && $form->validate){
> print "Content-type: text/html\n\nThe submition is valid";
>}else{
> print $form->render;
>}
>
>Template code:
><html>
><body>
><tmpl_var form-start>
>Name<tmpl_var field-name1><tmpl_var error-name1><br>
>Number<tmpl_var field-name2><tmpl_var error-name2><br>
><tmpl_var form-submit>
><tmpl_var form-end>
></body>
></html>
>
>
>
>
--
--
AmeriCorps VISTA (www.americorps.org/vista)
Community Software Lab
978-934-4350
www.communitysoftwarelab.org
RSS Feed