Remember that CFB has specifiedif( $form->submitted ) { if( $form->submitted eq 'Cancel' ) { return $self->mainmenu_form_generate( undef ); } if( $form->submitted eq '< Back' ) { # User wants to return to previous form return $self->upload2_form_generate( undef ); } ... other code to process 'Continue' button ... }
<input type="submit" name="_submit" value="Next >"
onClick="this.form._submit.value = this.value;">
to capture which button was clicked. So it consults the one name to get the value.
If I remember right CFB will substitute _all_ the HTML for all submit buttons when you reference [% form.submit %]. I think this is one reason I switched to generating my own buttons using an included TT2 file, not using CFB. I wanted a particular layout and CFB just lumped them all together.
In general, the more specific I got about the screen handling, the less useful CFB was for me. This is not unexpected if I read the author's comments correctly.
Since you are thinking about a cancel button on the same form, remember you may need to 'evade' the normal form error-checking when that button is clicked.
my $JSNoValdtnOnCancelBack = <<EOJSFUNC; if (form._submit.value == 'Cancel') { // skip validation since we're cancelling return true; } EOJSFUNC ... later ... $o .= $form->render( template => { type => 'TT2', ::::: }, jsfunc => $JSNoValdtnOnCancelBack, );
In reply to Re: CGI::FormBuilder Multiple Submit buttons and CGI::Application
by shenme
in thread CGI::FormBuilder Multiple Submit buttons and CGI::Application
by set_uk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |