[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&nbsp;&nbsp; =&gt; 'show_words',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Values =&gt; [ 'Yes', 'No' ] ) %]<br>[% CGI.submit %]<br>[% 
CGI.end_form %]
<br><br><br></span>I get:<br><br>&lt;form method=&quot;post&quot; action=&quot;&quot; enctype=&quot;multipart/form-data&quot;&gt;<br><br>&lt;select name=&quot;show_words&quot; &gt;<span class="q"><br>&lt;option value=&quot;Yes&quot;&gt;Yes&lt;/option&gt;
<br>&lt;option value=&quot;No&quot;&gt;No&lt;/option&gt;<br>&lt;/select&gt;<br></span>&lt;input type=&quot;submit&quot; name=&quot;.submit&quot; /&gt;<br>&lt;/form&gt;<br><br><br>No need to force scalar context or a join.&nbsp; 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> &lt;<a href="mailto:nicg@noslogan.org">nicg@noslogan.org
</a>&gt; 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>&gt; Hello all,
<br>&gt;<br>&gt; First post to this list, but I have been lurking for a while.<br>&gt;<br>&gt; I am using the CGI plugin to TT and am getting an array reference<br>&gt; when I<br>&gt; should be getting an HTML element.<br>
&gt;<br>&gt; Here is what I have written:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; [% CGI.start_form %]<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; [% CGI.popup_menu( Name&nbsp;&nbsp; =&gt; 'show_words',<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Values =&gt; [ 'Yes', 'No' ] ) %]<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; [% 
CGI.submit %]<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; [% CGI.end_form %]<br>&gt;<br>&gt; And here is what I get:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;form method=&quot;post&quot; action=&quot;/cgi-bin/auth/auth.cgi&quot;<br>&gt; enctype=&quot;multipart/form-data&quot;&gt;
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select name=&quot;show_words&quot; tabindex=&quot;1&quot;&gt;<br>&gt; &lt;option value=&quot;Yes&quot;&gt;Yes&lt;/option&gt;<br>&gt; &lt;option value=&quot;No&quot;&gt;No&lt;/option&gt;<br>&gt; &lt;/select&gt;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; tabindex=&quot;2&quot; name=&quot;.submit&quot; /&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; ARRAY(0x86eb4a0)<br>&gt;<br>&gt;<br>&gt; I am getting that last line; &quot;ARRAY(0x86eb4a0)&quot; instead of the
<br>&gt; expected &lt;/form&gt; tag.<br>&gt; Am I doing something wrong here?<br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[% 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--