Sam Tregar wrote:
On Mon, 3 May 2004, Mark Fuller wrote:

It just seems to me like "selected" and "checked" are fairly basic and
there's no easy (more built-in) way to accomodate them. It seems like you
recognize that they require a bit of ugliness. Why not provide for them
somehow?


Because CGI.pm already has it nailed.  Why reinvent the wheel?  And
you can't beat the simplicity:

  $template->param(year_select =>
                   scalar $query->popup_menu(-name => 'year',
                                             -values => [ 1970 .. 2020 ])
                  );

And in the template:

<tmpl_var year_select>

I've been doing it for years now and it's never done me wrong.

I have to agree with Sam on this one. I don't think there is a need to add features to handle select lists in HTML::Template. The issue of filling in HTML forms was solved ages ago, and doing it in HTML::Template is not (IMHO) the elegant way to do it.


Use CGI.pm as Sam suggests, or use HTML::FillInForm (my preferred method). These days the only thing that needs to be customized in a form element that a designer may need access to is the class attribute. If you define a standard naming convention, then having the class attribute in your code is not a big deal (the code already defines the name of the form element as well...). If you need to change the style dynamically, then load a different stylesheet for the page. Don't change the name of the class attribute...

The only thing that I can see where using CGI.pm to generate select boxes could hamper a designer is if they want to put a null option at the top of the list ( eg -- Choose a Year --). That would have to be encoded in the code which means the designer can't change it. That is one reason why I use HTML::FillInForm. I provide the template with a list of options (which the designer can put into a select box, or as a bunch of radio buttons formatted in a table, I don't care). Then HTML::FillInForm comes along afterwards and fills out the form regardless of how the designer decided to lay it out.

Both methods simplify your templates a great deal, and make life much easier for the template designer. That having been said, nothing is stopping you from continuing on using HTML::Template to fill in forms. It is a valid method that works well for many people.

Cheers,

Cees


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to