aptom has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
just started playing with Template Toolkit.
I cannot seem to put an array ref within a form field.
e.g.

in parent script my @bob = qw( 1 9 3 4 5 ); my $vars = { cgi => CGI->new(), array_ref => \@bob }; $tt->process('main_form.tt', $vars) || die $tt->error(), "\n"; =============================================================== in template (main_form.tt) [% cgi.scrolling_list({ name => 'languages', values => $array_ref }) %]
the output contains no values for the option tags.
anyone nutted this one out?
Thanks, Ap

Replies are listed 'Best First'.
Re: Template Toolkit and Array Refs in Form
by almut (Canon) on Jul 16, 2010 at 07:38 UTC
    [% cgi.scrolling_list({ name => 'languages', values => $array_ref }) %] ^

    Just get rid of the sigil (dollar sign).

      Almut,
      it works: thanks a million!!

      you wouldn't believe the permutations and combinations I tried to get this working.
      and it was so straightforward. DOH!!!