Mailing List Archive

Using CGI via template...
Hi there,

sorry if I need to direct this question elsewhere...

When display the page at http://localhost:3000/ I'm getting the
follwing output:
ARRAY(0xb2a138) <foo> ARRAY(0xa8e350)

Note: foo is a valid drop down list - but the arrays appearing are
weird.
The relevant section in the template is as follows.

<html>
...
[% USE CGI %]
[% CGI.start_form %]
[% CGI.checkbox_group({name => 'colours',
values => [ 'red', 'green', 'blue' ]})
%]
[% CGI.popup_menu({name => 'items',
values => ['foo', 'bar', 'baz' ]})
%]
[% CGI.end_form %]
...
</html>

what am I missing?

cheers,
LD
Using CGI via template... [ In reply to ]
Hi there,

On 13/04/2005, at 4:12 PM, LD wrote:

> When display[ing] the page at http://localhost:3000/ I'm getting the
> follwing output:
> ARRAY(0xb2a138) <foo> ARRAY(0xa8e350)
>
> Note: foo is a valid drop down list - but the arrays appearing are
> weird.
> The relevant section in the template is as follows.

funnily enough [% CGI.end_form %] is returning a list with ('<div>',
'</div>', '</form>').

So, I've resorted to:
[% MACRO scalar(list) GET list.join %]
...
[% CGI.start_form %]
[% scalar(CGI.checkbox_group({name => 'colours',
values => [ 'red', 'green', 'blue' ]}))
%]
[% scalar(CGI.end_form) %]

cheers,
LD
Using CGI via template... [ In reply to ]
On Wed, 13 Apr 2005, LD wrote:
> [% MACRO scalar(list) GET list.join %]
> [% scalar(CGI.end_form) %]

I'd suggest calling this something other than scalar() since the perl
scalar() has significantly different semantics than yours. Calling it
listcat() or listjoin() would be a lot less confusing to those of us who
think in Perl. :)

--
</chris>

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Using CGI via template... [ In reply to ]
On Wed, 13 Apr 2005, LD wrote:

> funnily enough [% CGI.end_form %] is returning a list with ('<div>',
> '</div>', '</form>').
>

When I do [% CGI.end_form %] I get an arrayref with ('<div>',
<input type="hidden" name=".cgifields" value="colours" />, '</div>',
'</form>'). The hidden input has to do with CGI.pm's handling of "sticky"
form fields, in this case the selected "colours" checkboxen.

I like the macro idea, though I would change the name, as mentioned
elsewhere. I don't use Template::Plugin::CGI much, but when I do, I've
always just said something like [% CGI.end_form.join("\n") %]. I join on
newline so the HTML source looks a little more readable.

Cheers,

Brian