Re: [htmltmpl] Dynamic TMPL_VAR names? Is it possible?
Brought to you by:
samtregar
From: Philip S T. <phi...@gm...> - 2002-08-14 13:59:30
|
Sometime on Aug 13, Fran Fabrizio assembled some asciibets to say: > <input type=text name=computer_1_name> > <input type=text name=computer_1_ip_address> > <input type=text name=computer_2_name> > <input type=text name=computer_2_ip_address> This is what I do, although I use it in a form to add authors to a publication. <tmpl_loop computers> <input type=text name="computer_<tmpl_var index>_name" value="<tmpl_var value>"> <tmpl_if error><span class="error><tmpl_var error></span> </tmpl_loop> This will not work with associate, but it's pretty simple to populate the template: my @computers; for(my $i=0; defined($cgi->param("computer_${i}_name")); $i++) { my %computer = ( index => $i, value => $cgi->param("computer_${i}_name"), error => check_param(...) ); push @computers, \%computer; } $template->param(computers => \@computers); -- It's hard to get ivory in Africa, but in Alabama the Tuscaloosa. -- Groucho Marx |