[Templates] Form problem with CGI plugin
Mike Friedman
friedo@friedo.com
Thu, 28 Sep 2006 14:14:25 -0400
------=_Part_12425_12770183.1159467265529
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
FWIW, using the following:
[% USE CGI %]
[% CGI.start_form %]
[% CGI.popup_menu( Name => 'show_words',
Values => [ 'Yes', 'No' ] ) %]
[% CGI.submit %]
[% CGI.end_form %]
I get:
<form method="post" action="" enctype="multipart/form-data">
<select name="show_words" >
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<input type="submit" name=".submit" />
</form>
No need to force scalar context or a join. This is with TT v. 2.15 and
TT::P::CGI v. 2.67.
Mike
On 9/27/06, Nic Gibson <nicg@noslogan.org> wrote:
>
>
> On Sep 27, 2006, at 10:18, Jeremiah Foster wrote:
>
> > Hello all,
> >
> > First post to this list, but I have been lurking for a while.
> >
> > I am using the CGI plugin to TT and am getting an array reference
> > when I
> > should be getting an HTML element.
> >
> > Here is what I have written:
> >
> > [% CGI.start_form %]
> > [% CGI.popup_menu( Name => 'show_words',
> > Values => [ 'Yes', 'No' ] ) %]
> > [% CGI.submit %]
> > [% CGI.end_form %]
> >
> > And here is what I get:
> >
> > <form method="post" action="/cgi-bin/auth/auth.cgi"
> > enctype="multipart/form-data">
> >
> > <select name="show_words" tabindex="1">
> > <option value="Yes">Yes</option>
> > <option value="No">No</option>
> > </select>
> > <input type="submit" tabindex="2" name=".submit" />
> > ARRAY(0x86eb4a0)
> >
> >
> > I am getting that last line; "ARRAY(0x86eb4a0)" instead of the
> > expected </form> tag.
> > Am I doing something wrong here?
> >
> > Thanks,
> >
> > Jeremiah
>
> Hi Jeremiah
>
> iirc, TT always calls methods in list context. end_form looks like it
> returns multiple
> values in list context.
>
> It's untested but you might try:
>
> [% CGI.end_form.join('') %]
>
> cheers
>
> nic
>
>
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates
>
------=_Part_12425_12770183.1159467265529
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
FWIW, using the following:<br><br>[% USE CGI %]<span class="q"><br><br>[% CGI.start_form %]<br>[% CGI.popup_menu( Name => 'show_words',<br> Values => [ 'Yes', 'No' ] ) %]<br>[% CGI.submit %]<br>[%
CGI.end_form %]
<br><br><br></span>I get:<br><br><form method="post" action="" enctype="multipart/form-data"><br><br><select name="show_words" ><span class="q"><br><option value="Yes">Yes</option>
<br><option value="No">No</option><br></select><br></span><input type="submit" name=".submit" /><br></form><br><br><br>No need to force scalar context or a join. This is with TT v.
2.15 and TT::P::CGI v. 2.67.<br><span class="sg"><br><br>Mike<br><br><br></span><br><div><span class="gmail_quote">On 9/27/06, <b class="gmail_sendername">Nic Gibson</b> <<a href="mailto:nicg@noslogan.org">nicg@noslogan.org
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>On Sep 27, 2006, at 10:18, Jeremiah Foster wrote:<br><br>> Hello all,
<br>><br>> First post to this list, but I have been lurking for a while.<br>><br>> I am using the CGI plugin to TT and am getting an array reference<br>> when I<br>> should be getting an HTML element.<br>
><br>> Here is what I have written:<br>><br>> [% CGI.start_form %]<br>> [% CGI.popup_menu( Name => 'show_words',<br>> Values => [ 'Yes', 'No' ] ) %]<br>> [%
CGI.submit %]<br>> [% CGI.end_form %]<br>><br>> And here is what I get:<br>><br>> <form method="post" action="/cgi-bin/auth/auth.cgi"<br>> enctype="multipart/form-data">
<br>><br>> <select name="show_words" tabindex="1"><br>> <option value="Yes">Yes</option><br>> <option value="No">No</option><br>> </select>
<br>> <input type="submit" tabindex="2" name=".submit" /><br>> ARRAY(0x86eb4a0)<br>><br>><br>> I am getting that last line; "ARRAY(0x86eb4a0)" instead of the
<br>> expected </form> tag.<br>> Am I doing something wrong here?<br>><br>> Thanks,<br>><br>> Jeremiah<br><br>Hi Jeremiah<br><br>iirc, TT always calls methods in list context. end_form looks like it
<br>returns multiple<br>values in list context.<br><br>It's untested but you might try:<br><br> [% CGI.end_form.join('') %]<br><br>cheers<br><br>nic<br><br><br>_______________________________________________<br>templates mailing list
<br><a href="mailto:templates@template-toolkit.org">templates@template-toolkit.org</a><br><a href="http://lists.template-toolkit.org/mailman/listinfo/templates">http://lists.template-toolkit.org/mailman/listinfo/templates
</a><br></blockquote></div><br>
------=_Part_12425_12770183.1159467265529--