in reply to Re: Re: Form with Table - FormBuilder, map, or template?
in thread Form with Table - FormBuilder, map, or template?

I suggest you look at HTML::Template. The philosophy of HTML::Template is that people who are good at HTML should do HTML, and people who are good at Perl should do Perl.

With HTML::Template, you can ask a friend or a proffesional to design the HTML part for you, and then simply fill in the missing values from Perl.

The template would look somewhat like this:

<table> <tr><th>Remove</th><th>Artist</th>.....</tr> <TMPL_LOOP name="cd_table"> <tr> <td><input type="checkbox" name="delete<TMPL_VAR name="__counter__"> +"</td> <td><TMPL_VAR name="artist"></td> <td><TMPL_VAR name="album"></td> <td><TMPL_VAR type=select name="combo1_<TMPL_VAR name="__counter__"> +">......</td> ..... # you get the idea </TMPL_LOOP> </table>
The Perl code is fairly simple: to set a TMPL_VAR you assign a value to it with $template->param(name=>value). To assign all the values to the rows of a TMPL_LOOP, you assign it a reference to an array of hashes, where each hash represents one row of the table, and the hashes contain the (variable name, variable value) pairs.

Note the __counter__ references above: they are meant to give each checkbox and each combobox a name associated with the row number in which it appears: that is the only way to know which checkbox or combobox the user has selected. Hope this helps...

Replies are listed 'Best First'.
Re: Re: Re: Re: Form with Table - FormBuilder, map, or template?
by Anonymous Monk on Mar 11, 2004 at 00:34 UTC
    Thanks a bunch, I'll start exploring that module then. <rant> It's so hard sometimes to find the right libraries / modules / add-ons to use. Bah! </rant> Just to be clear though, I mean for a user to be able to submit all / some rows in one operation - I guess this is the part that confused me with FormBuilder. Anyway, I'll get hacking, and thanks again.
      Just thought I'd update on this. I found a very good implementation at http://www.perlmonks.org/index.pl?node_id=139295, and it works like a charm now. Thanks again to all the knowledgable monks at this excellent site!