You can have multiple submit buttons, but let CFB figure out which one was used.   I don't remember my investigations on this, but my code ended up using
if( $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 ... }
Remember that CFB has specified
<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

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.