Re: [Templates] [PL] Coding for Y/N radio buttons
[prev]
[thread]
[next]
[Date index for 2004/10/30]
On Fri, 29 Oct 2004, Todd Freeman wrote:
> An easier way of doing this is with the CGI module... pass a CGI
> object (in this case 'q') to the template and you can do fun stuff
> like:
I wish you guys would quit this. Now I have to rethink my design/code to
make it easier to maintain and pass along. (There goes the job security!
:-)
> [% q.radio_group(name => 'GETS_REPORT',
> values=>['T','F'],
> default=>gets_report,
> labels=>{'T'=>'Yes','F'=>'No'}
> ); %]
>
> If you want to get fancier you make stuff persistent:
This will take some doing. Currently I'm pulling the fileds/values in
from the form and placing them in another hash that is passed around
script for adding to and modifying.
my $SignUp = new CGI
my %SUI;
...
my @PARAMS = $SignUp->param;
map {$SUI{$_} = $SignUp->param($_)} @PARAMS;
and then I slice and dice %SUI
This seemed to make more sense and was less typing then
$SignUp->param(gets_report) = 'T'; (Have I got this right?)
> [% SET TFlabels = {'T'=>'Yes','F'=>'No'}; %]
> [% SET TFvalues = ['T','F']; %]
> [% q.radio_group(name => 'GETS_REPORT',
> values=>TFvalues,
> default=>q.param('GETS_REPORT'),
> labels=>TFlabels}
> ); %]
>
> And you can then add more radio groups with the same params dead
> simply... Like say you have an array of questions in a hash with the
> keys as labels
>
>
> [% SET TFlabels = {'T'=>'Yes','F'=>'No'}; %]
> [% SET TFvalues = ['T','F']; %]
> [% FOREACH question = questions.keys %]
> [% q.radio_group(name => question,
> values=>TFvalues,
> default=>q.param(questions.$question),
> labels=>TFlabels}
> ); %]
> [% END %]
>
> VOILA!
>
> BTW... I have noticed that most of the people asking questions and
> showing DBI examples and such seem to hardcode their HTML... am I
> doing something evil by using the CGI module for all this?
I'd love to but my coding jumps from from type of project to another. I
never get a chance to come close to mastering CGI.pm. Also I'm qiute
often given designs done in Frontpage or Dreamweaver and I am unwilling to
translate that to good clean xhtml since about 3 seconds after I get it
done a totally new design will come out.
I have done a few scripts without TT using CGI before I discovered TT.
Now the design is looked into the code so I have to modify the look
(there's job security coming back.)
But your example using CGI with TT will make me re-look at several project
for recoding. The think I really link is I can display the template file
and tweak the layout and not worry too much about the back-end coding.
Praise be to the lords of perl!
Rod
--
"Open Source Software - You usually get more than you pay for..."
"Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
(message missing)
|