=head2 _prepare_looped_variables This method exists to prepare fields which will ultimately be rendered inside of loops by the template, to be prepared for inclusion. This permits one to iterate over a database query and generate one or more form fields for each record, which are rendered with HTML::Template. This method is intended to add one new template construct: making possible the following code: my $form = CGI::FormBuilder->new( template => '/path/to/template/below.tmpl', header => $header, submit => [ 'Process Group Action' ] ); $form->field( name => 'group_action', label => 'Action', type => 'select', options => { 'add_to_group' => 'Add to Group', 'remove_from_group' => 'Remove from Group', 'edit_group' => 'Edit Group', 'delete_from_list' => 'Delete from List' } ); 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->{'phone_number_id'}); push (@loop_data, \%row_data); } $form->tmpl_param(PHONES => \@loop_data); my ($html); if ($form->submitted && $form->validate) { my $field = $self->{'q'}->Vars; if($form->submitted eq 'Process Group Action'){ if($field->{'group_action'} eq 'add_to_group'){ $self->_add_phone_numbers_to_group($field); $self->{'q'}->delete('_submitted_Group_Actions'); } elsif($field->{'group_action'} eq 'remove_from_group'){ $self->_remove_phone_numbers_from_group($field); $self->{'q'}->delete('_submitted_Group_Actions'); } elsif($field->{'group_action'} eq 'edit_group'){ $self->_edit_group($field); $self->{'q'}->delete('_submitted_Group_Actions'); } elsif($field->{'group_action'} eq 'delete_from_list'){ $self->_delete_phone_numbers_from_list($field); $self->{'q'}->delete('_submitted_Group_Actions'); } } $html = $form->render(); } else { $html = $form->render(); } Using a template like the one below: /path/to/template/below.tmpl

Group Actions:

INSERT_NEW_RECORD_HERE
Call Group: Group Action:
TagFirst NameLast NameEmailPhoneActions
=cut