[html-formfu] New user with simple question

xaos xaos at darksmile.net
Wed May 25 06:38:31 GMT 2011


Hello everyone,

I have 4 files that I am using to test HTML::FormFu
and I am just "not getting it".

This is the sequence of events:

The user+browser calls http://localhost/cgi-bin/simple.cgi
simple.cgi gets called and the form shows up on the browser.
The user fills in the single field.
The CGI script that is supposed to do the form processing:
     "simple_get.cgi"
gets called but cannot return a positive from:
     $form->submitted;

I have included all 4 files.

I figure this is the simplest, complete, example of using HTML::FormFu.

What am I doing wrong?

Any help would be appreciated as I am going nuts over
this.

Many Thanks in Advance,

George
======================

The relevant files:
First, the yml file: simple.yml
======================
---
     auto_fieldset: 1
     elements:
         - type: Text
           name: textvar
...
======================

Next, the HTML file: simple.shtml
======================
<HTML>
<HEAD>
<TITLE>Test Template</TITLE>
</HEAD>
<BODY>
                 Form:
<p>
<TMPL_VAR NAME="form">
</p>
<BR>
</BODY>
</HTML>
======================

Next,  the initial CGI file: simple.cgi
======================
   1 #!/usr/bin/perl
   2 #
   3 # @(#)
   4 #
   5 use strict;
   6 use warnings;
   7 use HTML::FormFu;
   8 use YAML::Syck qw( Load );
   9 use CGI qw(:standard);
  10 use HTML::Template;
  11
  12 use vars qw ($cgi_query $template $form $formret $TimeFormat);
  13 use vars qw ($RstrLdate $RstrLtime);
  14 #
  15 #
  16 my($query, $template, $formret);
  17 my($template_out);
  18
  19 $query = new CGI;
  20 print $query->header();
  21
  22 #
  23 # open the HTML template
  24 $form = HTML::FormFu->new;
  25 $form->load_config_file('/opt/http/forms/simple.yml');
  26 $form->action("/cgi-bin/simple_get.cgi");
  27 $form->method("post");
  28 $form->indicator("textvar");
  29 $form->process( $cgi_query );
  30
  31 $template = HTML::Template->new(filename => '/opt/http/templates/simple.shtml');
  32
  33 # fill in some parameters in the template
  34 if ( $form->submitted ) {
  35     `/bin/echo "proc: submittted" >>/tmp/http.log`;
  36 } else {
  37     `/bin/echo "proc: Not-submittted" >>/tmp/http.log`;
  38     #
  39     # Show form to user via apache
  40     $template->param( form => $form );
  41     $template_out = $template->output;
  42     print $template_out . "\n";
  43 }
======================

And last, the processing CGI file: simple_get.cgi
======================
   1 #!/usr/bin/perl
   2 #
   3 # @(#)
   4 #
   5 use strict;
   6 use warnings;
   7 use HTML::FormFu;
   8 use YAML::Syck qw( Load );
   9 use CGI qw(:standard);
  10 use HTML::Template;
  11
  12 use vars qw ($cgi_query $template $form $formret $TimeFormat);
  13 use vars qw ($RstrLdate $RstrLtime);
  14 #
  15 #
  16 my($query, $template, $formret);
  17 my($template_out);
  18
  19 $query = new CGI;
  20 print $query->header();
  21 #
  22 # open the HTML template
  23 $form = HTML::FormFu->new;
  24 $form->load_config_file('/opt/http/forms/simple.yml');
  25 #$form->action("/cgi-bin/simple_get.cgi");
  26 #$form->method("post");
  27 $form->indicator("submit");
  28 $form->process();
  29
  30 $template = HTML::Template->new(filename => '/opt/http/templates/simple.shtml');
  31
  32 # fill in some parameters in the template
  33 if ( $form->submitted ) {
  34     `/bin/echo "proc: submittted" >>/tmp/http.log`;    # We never get here!!!
  35 } else {
  36     `/bin/echo "proc: Not-submittted" >>/tmp/http.log`;
  37     $template->param( form => $form );
  38     $template_out = $template->output;
  39     print $template_out . "\n";
  40 }
======================






More information about the HTML-FormFu mailing list