Hi Folks,
OK, I've been banging my head against this problem long enough.
Hopefully someone can help.
I'm working on a C::A application that consists of a multiple-page
form. I'm using the following plugins to ease the way:
C::A::Plugin::Session
C::A::Plugin::ValidateRM
Each page of the form has it's own display and process runmodes. Each
page, except the first and last, has both "continue" and "go back"
buttons that the process runmodes use to determine if I'm validating
new data and wanting to move on to the next step, or simply wanting
to go back to the previous page to make a change:
Snippet
======
sub step2_membership_type {
my $self = shift;
my $errs = shift;
my $q = $self->query;
$self->_get_session();
# Process the template
my $template
= $self->load_tmpl( 'step2_membership_type.tmpl', associate => $q );
$template->param($errs) if $errs;
#Display the form
return $template->output();
}
sub process_step2 {
my $self = shift;
my $q = $self->query;
if ( $q->param('submit') eq 'Go Back' ) {
return $self->step1_app_type();
}
# validate the input
my ( $results, $err_page )
= $self->check_rm( 'step2_membership_type',
$self->cfg('profile_step2') );
return $err_page if $err_page;
$self->_save_session($results);
#move on to next step
return $self->step3_contact_info();
}
sub _save_session {
my $self = shift;
my $results = shift;
foreach my $field ( $results->valid() ) {
next unless $field =~ /^app_/;
$self->session->param( $field, $results->valid($field) );
}
}
sub _get_session {
my $self = shift;
# Loads session parameters into a query object.
$self->session->load_param( $self->query );
}
Note: the two routines, _get_session() and _save_session take care of
saving form data to the session object.
The problem arises when I use a "Go Back" button to return to a
previous page. The form does display with the fields properly filled
out with the info I submitted earlier (thanks to ValidateRM) but if I
resubmit the form with new data, the old data sticks; I cannot change
my previous entries.
I suspect that this is the result of the infamous sticky parameter
behavior of CGI, but my understanding is that feature/problem is
limited to form widgets created using CGI's tag generation shortcuts.
If I'm wrong about that, I'm still at a loss as to how to ensure that
resubmitting a form a prefilled form gets me the new data and not the
old.
Someone please put me out of my miserly and give a tired, clueless
guy a clue...
Thanks for your time.
Regards,
Sergej
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]