sub _render_online_household_form { my $self = shift; my $hh_values = shift; my $form = CGI::FormBuilder->new( name => 'phone_canvas_household', method => 'post', stylesheet => '', values => $hh_values, title => 'Phone Canvas a Household', submit => ['Reset this Household', 'Proceed to Next Household','Save Results'], keep_extras => 1, sticky => 1, ); my $mode; if(defined($hh_values->{'hh_id'})){ my $mode = $form->cgi_param('mode') || 'canvas'; } else { $hh_values = $self->_obtain_next_household(); $form->cgi_param( name => 'mode', value => 'next_hh' ); } # lots of form field definition statements if($mode eq 'canvas'){ print STDERR "Our mode is 'canvas'. \n"; if($form->submitted && $form->validate){ my $field = $form->fields; if($form->submitted eq 'Proceed to Next Household'){ print STDERR "\$form->submitted is now: " . $form->submitted . "\n"; $self->_record_call_results($field); my %field_options = ( name => 'mode', type => 'hidden', value => 'next_hh', ); $form->field( \%field_options ); $www_hh_form = $form->render(header => 1); # $www_hh_form .= "
" . Dumper(\$field) . ""; return $www_hh_form; } elsif($form->submitted eq 'Save Results') { $self->_record_call_results($field); # $www_hh_form = $form->confirm(header => 1); $www_hh_form = $self->_render_dashboard(); $www_hh_form .= "
" . Dumper(\$field) . ""; print STDERR "\$form->submitted is now: " . $form->submitted . "\n"; return $www_hh_form; } elsif($form->submitted eq 'Reset this Household') { my $record_count = $self->_reset_hh_call_results($field); $www_hh_form = $form->render(header => 1); print STDERR "\$form->submitted is now: " . $form->submitted . "\n"; return $www_hh_form; } else { print STDERR "Form invoked with illegal submit button from IP: \n"; die "Form invoked with illegal submit button from IP: \n"; } } else { print STDERR "OK, we'll render form for first time for this household.\n"; print STDERR "\$form->submitted is now: " . $form->submitted . "\n"; $www_hh_form = $form->render(header => 1); return $www_hh_form; } } elsif($mode eq 'next_hh'){ print STDERR "Our mode is 'next_hh'. \n"; $self->_obtain_next_household(); my %field_options = ( name => 'mode', type => 'hidden', value => 'canvas', ); $form->field( \%field_options ); } }