CGI::Application::Plugin::FormState

CGI::Application::Plugin::FormState can store form state without hidden fields.
Download

CGI::Application::Plugin::FormState Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Michael Graham
  • Publisher web site:
  • http://search.cpan.org/~mgraham/

CGI::Application::Plugin::FormState Tags


CGI::Application::Plugin::FormState Description

CGI::Application::Plugin::FormState can store form state without hidden fields. CGI::Application::Plugin::FormState can store form state without hidden fields.SYNOPSISFormState is just a temporary stash that you can use for storing and retrieving private parameters in your multi-page form. use CGI::Application::Plugin::FormState; my $form = < < EOF; < form action="app.cgi" > < input type="hidden" name="run_mode" value="form_process_runmode" > < input type="hidden" name="cap_form_state" value="< tmpl_var cap_form_state >" > ... < /form > EOF sub form_display_runmode { my $self = shift; # Store some parameters $self- >form_state- >param('name' = > 'Road Runner'); $self- >form_state- >param('occupation' = > 'Having Fun'); my $t = $self- >load_tmpl(scalarref = > $form); return $t- >output; } sub form_process_runmode { my $self = shift; # Retrieve some parameters print $self- >form_state- >param('name'); # 'Road Runner' print $self- >form_state- >param('occupation'); # 'Having Fun' }EXAMPLE ^This is a more complete example, using CGI::Application::Plugin::ValidateRM. use CGI::Application::Plugin::Session; use CGI::Application::Plugin::FormState; use CGI::Application::Plugin::ValidateRM; my $form = < < EOF; < form action="app.cgi" > < input type="hidden" name="run_mode" value="my_form_process" > < input type="hidden" name="cap_form_state" value="< tmpl_var cap_form_state >" > ... < /form > EOF sub my_form_display { my $self = shift; my $errs = shift; my $t = $self- >load_tmpl(scalarref = > $form); # Stash some data into it $self- >form_state- >param('name' = > 'Wile E. Coyote'); $self- >form_state- >param('occupation' = > 'Mining Engineer'); # Normal ValidateRM error handling $t- >param($errs) if $errs; return $t- >output; } sub my_form_process { my $self; # Normal ValidateRM validation my ($results, $err_page) = $self- >check_rm('my_form_display','_my_form_profile'); return $err_page if $err_page; # The data from the submitted form my $params = $self- >dfv_results; $params- >{'name'} = $self- >form_state- >param('name'); # 'Wile E. Coyote' $params- >{'occupation'} = $self- >form_state- >param('occupation'); # 'Mining Engineer' # Now do something interesting with $params # ... my $t = $self- >load_tmpl('success.html'); return $t- >output; } # Standard ValiateRM profile sub _my_form_profile { return { required = > 'email', msgs = > { any_errors = > 'some_errors', prefix = > 'err_', }, }; } Requirements: · Perl


CGI::Application::Plugin::FormState Related Software