[Templates] Way of using CGI and checkboxes is giving problems

Rafael Caceres rcaceres@aasa.com.pe
Tue, 26 Nov 2002 08:37:15 -0500


Mark:

Using [% query.end_form.list.join %] instead of just [% query.end_form 
%]  worked like a charm, thanks a lot.

Rafael


At 10:28 PM 11/25/2002 +0000, Mark Fowler wrote:
>Rafael wrote:
>
> > The checkbox fields, placed like:
> > Active: [% query.checkbox({name=>'ACTIVE',label=>" "}) %]
> > are causing the [% query.end_form %] at the end of the form to appear as:
> > ARRAY(0x12345).
>
>Try running this:
>
>   #!/usr/bin/perl
>
>   use CGI;
>   use Data::Dumper;
>
>   my $q = CGI;
>   print Dumper [$q->checkbox(-name => "foo")];
>   print Dumper [$q->end_form];
>
>This prints out:
>
>   $VAR1 = [
>             '<input type="checkbox" name="foo" value="on" />foo'
>           ];
>   $VAR1 = [
>             '<input type="hidden" name=".cgifields" value="foo" />',
>             '</form>'
>           ];
>
>You can see that end_form is now actually returning two values (including
>a hidden form.)  TT treats this as a list ref.  You probably want to
>simply join them, which can be done like so:
>
>   [% query.end_form.list.join %]
>
>The .list. bit ensures that end_form is a list (even if it has just one
>element.  The virtual methods are described in the manual here:
>
>http://www.template-toolkit.org/docs/leon/Manual/VMethods.html
>
>Hope that's helpful.
>
>Mark.
>
>--
>s''  Mark Fowler                                     London.pm   Bath.pm
>      http://www.twoshortplanks.com/              mark@twoshortplanks.com
>';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
>){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}
>
>_______________________________________________
>templates mailing list
>templates@template-toolkit.org
>http://lists.ourshack.com/mailman/listinfo/templates