1CGI::Application::PlugiUns:e:rSuCpoenrtFroirbmu(t3e)d PeCrGlI:D:oAcpupmleinctaattiioonn::Plugin::SuperForm(3)
2
3
4

NAME

6       CGI::Application::Plugin::SuperForm - Create sticky HTML forms in
7       CGI::Application run modes using HTML::SuperForm
8

SYNOPSIS

10           use CGI::Application::Plugin::SuperForm;
11
12               sub form_runmode {
13                       my $c = shift;
14
15                       my $form_start = $c->superform->start_form(
16                               {
17                                       method => "POST",
18                                       action => $c->query()->url() . "/myapp/form_process",
19                               }
20                       );
21
22                       my $text = $c->superform->text( name => 'text', default => 'Default Text' );
23
24                       my $textarea = $c->superform->textarea(
25                               name    => 'textarea',
26                               default => 'More Default Text'
27                       );
28
29                       my $select = $c->superform->select(
30                               name    => 'select',
31                               default => 2,
32                               values  => [ 0, 1, 2, 3 ],
33                               labels  => {
34                                       0 => 'Zero',
35                                       1 => 'One',
36                                       2 => 'Two',
37                                       3 => 'Three'
38                               }
39                       );
40
41                       my $output = <<"END_HTML";
42                   <html>
43                   <body>
44                       <form>
45                       Text Field: $text<br>
46                       Text Area: $textarea<br>
47                       Select: $select
48                       </form>
49                   </body>
50                   </html>
51               END_HTML
52                       return $output;
53
54               }
55

DESCRIPTION

57       Create sticky forms with "HTML::SuperForm".
58

METHODS

60       sform
61           alias to superform
62
63       superform
64           Returns a instance of "HTML::SuperForm" preconfigured with sticky
65           and fallback options on.  See HTML::SuperForm for more information
66           and examples.
67

EXAMPLE USING TT PLUGIN

69       A simplistic but working app SuperForm, TT and AutoRunmode plugins.  TT
70       brings in 'c' var to templates automatically, SuperForm brings in
71       'sform'.
72
73         Files:
74
75           ./lib/MyApp.pm
76           .MyApp/form.tmpl
77           ./server.pl
78
79         lib/MyApp.pm
80
81                       package MyApp;
82                       use base 'Titanium';
83
84                       use CGI::Application::Plugin::TT;
85                       use CGI::Application::Plugin::SuperForm;
86                       use CGI::Application::Plugin::AutoRunmode;
87
88                       sub form: Runmode{
89                               my $c = shift;
90                               $c->tt_process();
91                       }
92
93
94                       sub process_form(): Runmode{
95                               my $c = shift;
96                               # do something with user input.
97                               # redirect to success page, etc.
98                               return "You said: ". $c->query()->param('input1');
99                       }
100
101
102
103                       1;    # End of MyApp
104
105         MyApp/form.tmpl
106
107                 <html>
108                       [% c.sform.start_form({method=>"POST"}) %]<br/>
109                       Say what? [% c.sform.text({name=>"input1"}) %]<br/>
110                       [% c.sform.hidden({name=>"rm", value=>"process_form"})  %]<br/>
111                       [% c.sform.submit()%]<br/>
112                       [% c.sform.end_form() %]<br/>
113                 </html>
114
115         .server.pl
116
117                       use warnings;
118                       use strict;
119                       use CGI::Application::Server;
120                       use lib 'lib';
121                       use MyApp;
122
123                       my $app = MyApp->new(PARAMS => {});
124                       my $server = CGI::Application::Server->new();
125                       $server->document_root('.');
126                       $server->entry_points({
127                           '/index.cgi' => $app,
128                       });
129                       $server->run;
130

SEE ALSO

132       HTML::SuperForm, Titanium, CGI::Application.
133

AUTHOR

135       Gordon Van Amburg, "gordon@minipeg.net"
136

LICENSE

138       This library is free software. You can redistribute it and/or modify it
139       under the same terms as perl itself.
140
141
142
143perl v5.38.0                      2023-07C-G2I0::Application::Plugin::SuperForm(3)
Impressum