This is a second attempt to succinctly state this issue. For those who feel the need to see further code, my complete (non-working) subroutine is posted at:
http://perlmonks.com/?node_id=763253

I am working to generate a form dynamically from database calls.

I need to generate a form checkbox for each phone record pulled from my query. I would have thought that setting my %row_data{'CHECKBOX'} to a $form->field() object would have done the trick, but apparently not. Data::Dumper says it is: "'CHECKBOX' => 'perform_group_action'", instead of an entire form element. Commenting out the 'value' key leaves CHECKBOX undefined, commenting out the 'options' key throws errors reading: "No options specified for 'checkbox' field".

The name of the checkbox field changes on each iteration through the list. How do I invoke a "<tmpl-var field-checkbox>" with a changing fieldname and embedded in rows of my template?

I'm looking for a clue here. Anybody have one to spare?

-- Hugh

My template reads:

<DIV align="right" id="GroupAction" class="GroupAction" title="Group_A +ction"> <h3>Group Actions:</h3> <table> <tmpl_var form-start> <tr><td colspan="2"></td><td colspan="2">Call Group: <tmpl_var field-g +roup> Group Action: <tmpl_var field-group_action></td><td colspan="2" +><tmpl_var form -submit></td></tr> <tr><th>Tag</th><th>First Name</th><th>Last Name</th><th>Email</th><th + +>Phone</th><th>Actions</th></tr> <tmpl_loop name="PHONES"> <tr><td> <tmpl-var field-checkbox> </td><td> <tmpl-var name=FNAME> </t +d><td> <tmpl-var name=LNAME> </td><td> <tmpl-var name=EMAIL> </td><td +> <tmpl-var name=PHONE> </td><td> <tmpl-var name=LINKS> </td></tr> </tmpl_loop> <tmpl_var form-end> INSERT_NEW_RECORD_HERE </table> </DIV>
------------------------------------

And the problematic portion of my code reads:

my @loop_data; while (my $phone = $sth->fetchrow_hashref()){ my %row_data; my $name = 'group_action_' . $phone->{'phone_number_id'}; $row_data{'CHECKBOX'} = $form->field( name => $name, label => '', type => 'checkbox', options => [ 'perform_group_action' ], sticky => 0, value => 'perform_group_action', ); $row_data{'FNAME'} = $phone->{'fname'}; $row_data{'LNAME'} = $phone->{'lname'}; $row_data{'EMAIL'} = $phone->{'email'}; $row_data{'PHONE'} = $phone->{'phone'}; $row_data{'LINKS'} = $self->_get_links_for_phone_list( $phone->{'p +hone_number_id'} ); push (@loop_data, \%row_data); } $form->tmpl_param(PHONES => \@loop_data); print STDERR "The loop_data incldes: \n" . Dumper(\@loop_data);
if( $lal && $lol ) { $life++; }

In reply to CGI::FormBuilder, HTML::Template and \@loop_data question; trying again by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.