While you're at it you might reconsider giant if/else trees, even though a lot of people, even smart poeple, like/use them

I find this to read, easier to maintain

#!/usr/bin/perl -- use strict; use warnings; use CGI::FormBuilder; Main( @ARGV ); exit( 0 ); sub Main { my $cgi = CGI->new; # Our "mode" parameter determines what we do my $mode = $cgi->param('mode') || 'default'; # Change our form based on our mode if ($mode eq 'view') { modeView( $cgi ); } elsif ($mode eq 'edit') { modeEdit( $cgi ); } else { modeDefault( $cgi ); } } sub modeDefault { ... } sub modeEdit { ... } sub modeView { my ( $cgi ) = @_; my $form = CGI::FormBuilder->new( method => 'post', fields => [qw(...)], params => $cgi # get CGI params ); ... if ($form->submitted && $form->validate) { print $form->confirm; } else { print $form->render; } }

But if you go that approach, you might as well use a little standard sugar

#!/usr/bin/perl -- use strict; use warnings; use CGI::Application; use CGI::FormBuilder; Main( @ARGV ); exit( 0 ); sub Main { MyAppname->new->run; } BEGIN { package MyAppname; use parent 'CGI::Application'; use CGI::Application::Plugin::AutoRunmode; use CGI::Application::Plugin::DebugScreen; sub What : Runmode { CGI::FormBuilder->new->render; } sub Edit : Runmode { ... } sub View: StartRunmode { my ( $cgiapp ) = @_; my $form = CGI::FormBuilder->new( method => 'post', fields => [qw( one two three )], params => $cgiapp->query, # get CGI params ); if ($form->submitted && $form->validate) { # you don't print in CGI::Application return $form->confirm; } else { return $form->render; } } }

In reply to Re^9: FormBuilder fails in "Multi screen mode" by Anonymous Monk
in thread [Resolved]FormBuilder fails in "Multi screen mode" by kazak

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.