Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^6: FormBuilder fails in "Multi screen mode"

by kazak (Beadle)
on Aug 23, 2012 at 12:46 UTC ( [id://989312]=note: print w/replies, xml ) Need Help??


in reply to Re^5: FormBuilder fails in "Multi screen mode"
in thread [Resolved]FormBuilder fails in "Multi screen mode"

Thanks, I'll look on my code again. May be I confused you with my vague explanations, but your example is not reflecting what I'm trying to do. I here it is: Example: "Multi screen mode"

Replies are listed 'Best First'.
Re^7: FormBuilder fails in "Multi screen mode"
by Anonymous Monk on Aug 23, 2012 at 12:49 UTC

    May be I confused you with my vague explanations, but your example is not reflecting what I'm trying to do.

    Sure it is.

      Thank you, I resolve this problem. In example that I gave you one parameter was missing :"params => $query", I found it out from docs you gave me, thanks.

        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; } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://989312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-28 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found