Re: [htmltmpl] Radio button question
Brought to you by:
samtregar
From: Jason P. <ja...@jo...> - 2004-02-11 16:07:10
|
>> <input type="radio" name="Color" value="Red" <!--TMPL_VAR NAME=Red -->"> >> <input type="radio" name="Color" value="Blue" <!--TMPL_VAR NAME=Blue >> -->"> >> >> But the above is really ugly, and I gotta believe >> there's a better approach (that I'm too dense to recognize) > Yeah, I know, it seems like there should be a better solution. In fact, > due to the limitations of HTML, there are only a series of equally sucky > solutions. What you have above is as good as any. Blame W3C. I would recommend checking out HTML::FillInForm for your situation - it'll take care of those radio buttons and select boxes, since you're rehashing the same form if you didn't receive valid input. Something like this un-tested code: # You're processing the input from the form... if ( bad_input( $query ) ) { $template = HTML::Template->new( 'filename' => 'previous_steps_template.TMPL', 'die_on_bad_params' => 0, ); $fif = HTML::FillInForm->new; print $fif->fill( 'scalarref' => $template->output, 'fobject' => $query ); exit; } You'll be amazed how cool FillInForm will work ... you won't need to do that TMPL_VAR stuff inside the form fields ... FillInForm will handle all that for you. HTH, Jason |