[html-formfu] New user with simple question -- Solved

George Hrysanthopoulos xaos at darksmile.net
Wed May 25 08:39:02 GMT 2011


Ok, problem solved! Phew!

I will post all the files in downloadable form
at "http://www.xm5design.com/" sometime tomorrow.
After I wake up!

Thanks Carl! You have made my day(night).

Now, I can go to sleep!

George

Solution: The "simple_get.cgi" script must look like this:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
   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, $CGI_query);
  18
  19 #
  20 # Note: When calling "new CGI" the variables (as passed by apache) wil=
l fill in the
  21 #           query and each variable can be accessed via: $form->param_=
value('variable_name_in_form')
  22 $CGI_query =3D new CGI;
  23 print $CGI_query->header();
  24     #
  25     # open the HTML template
  26     $form =3D HTML::FormFu->new;
  27     $form->load_config_file('/opt/http/forms/simple.yml');
  28     $form->action("/cgi-bin/simple_get.cgi");
  29     $form->method("post");
  30     $form->indicator("textvar");
  31     $form->query( $CGI_query ) ;
  32     $form->process();
  33
  34     $template =3D HTML::Template->new(filename =3D> '/opt/http/templat=
es/simple.shtml');
  35     #
  36     # fill in some parameters in the template
  37     if ( $form->submitted ) {
  38         `/bin/echo "proc: submittted" >>/tmp/http.log`;
  39         #
  40         $template->param( form =3D> $form->param_value('textvar') );
  41         $template_out =3D $template->output;
  42         print $template_out . "\n";
  43     } else {
  44         `/bin/echo "proc: Not-submittted" >>/tmp/http.log`;
  45         $template->param( form =3D> $form );
  46         $template_out =3D $template->output;
  47         print $template_out . "\n";
  48     }
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
  On 5/25/11 3:41 AM, George Hrysanthopoulos wrote:
> Ok, what would be an example of a "$query object".
>
> I know, I know, but Google is not helping me!
>
> George
> On 5/25/11 3:27 AM, Carl Franks wrote:
>>
>> Ah, yes -in the cgi handling the submission, process() needs to be passe=
d the $query object
>>
>> On 25 May 2011 08:19, "George Hrysanthopoulos" <xaos at darksmile.net <mail=
to:xaos at darksmile.net>> wrote:
>> > Carl,
>> >
>> > You are quite right. However, even when I did:
>> >
>> > 27 $form->indicator("textvar");
>> >
>> > I still got same result. Actually I had a button there
>> > called: "submit" but I removed it for the sake
>> > of simplicity.
>> >
>> > How is my overall logic?
>> >
>> > -George
>> >
>> > On 5/25/11 3:04 AM, Carl Franks wrote:
>> >>> First, the yml file: simple.yml
>> >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> >>> ---
>> >>> auto_fieldset: 1
>> >>> elements:
>> >>> - type: Text
>> >>> name: textvar
>> >>> And last, the processing CGI file: simple_get.cgi
>> >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> >>> 27 $form->indicator("submit");
>> >> indicator('submit') tells process() that a form must have a value for
>> >> the field 'submit'.
>> >> Your form config doesn't have a 'submit' field/button.
>> >> So $form->submitted() will always be false.
>> >>
>> >> Carl
>> >>
>> >> _______________________________________________
>> >> HTML-FormFu mailing list
>> >> HTML-FormFu at lists.scsys.co.uk <mailto:HTML-FormFu at lists.scsys.co.uk>
>> >> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>> >>
>> >
>> >
>> > _______________________________________________
>> > HTML-FormFu mailing list
>> > HTML-FormFu at lists.scsys.co.uk <mailto:HTML-FormFu at lists.scsys.co.uk>
>> > http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>>
>>
>> _______________________________________________
>> HTML-FormFu mailing list
>> HTML-FormFu at lists.scsys.co.uk
>> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20110525/17=
b27582/attachment.htm


More information about the HTML-FormFu mailing list