CGI::Ap...uperForm(3)

πŸ“¦
version 0.5 Β· 2 versions
, in fedora 43

🌸 NAME 🌸

CGI::Application::Plugin::SuperForm β€” create sticky HTML forms in CGI::Application run modes using HTML::SuperForm. bestie. sticky forms. we love to see it πŸ’–


✨ SYNOPSIS ✨

    use CGI::Application::Plugin::SuperForm;

        sub form_runmode {
                my $c = shift;

                my $form_start = $c->superform->start_form(
                        {
                                method => "POST",
                                action => $c->query()->url() . "/myapp/form_process",
                        }
                );

                my $text = $c->superform->text( name => 'text', default => 'Default Text' );

                my $textarea = $c->superform->textarea(
                        name    => 'textarea',
                        default => 'More Default Text'
                );

                my $select = $c->superform->select(
                        name    => 'select',
                        default => 2,
                        values  => [ 0, 1, 2, 3 ],
                        labels  => {
                                0 => 'Zero',
                                1 => 'One',
                                2 => 'Two',
                                3 => 'Three'
                        }
                );

                my $output = <<"END_HTML";
            <html>
            <body>
                <form>
                Text Field: $text<br>
                Text Area: $textarea<br>
                Select: $select
                </form>
            </body>
            </html>
        END_HTML
                return $output;

        }

okay so that's the whole vibe in one run mode β€” you grab your form bits, you smash them into a heredoc, you return it. the fields stay sticky, which is the whole point. slay πŸ’…


🫢 DESCRIPTION 🫢

Create sticky forms with HTML::SuperForm. that's it, that's the pitch, and it ate. ✨


πŸ‘‘ METHODS πŸ‘‘

  • sform β€” an alias to superform. same energy, shorter name. iykyk πŸ’œ
  • superform β€” hands you back an instance of HTML::SuperForm that's preconfigured with sticky and fallback options on. wanna know more? more info and examples live over in HTML::SuperForm. go look, bestie πŸ¦‹

πŸŽ€ EXAMPLE USING TT PLUGIN πŸŽ€

A simplistic but working app SuperForm, TT and AutoRunmode plugins. TT brings in c var to templates automatically, SuperForm brings in sform. no cap, that's the whole setup 🌈

πŸ“ Files:

  ./lib/MyApp.pm
  .MyApp/form.tmpl
  ./server.pl

πŸ’– lib/MyApp.pm

            package MyApp;
            use base 'Titanium';

            use CGI::Application::Plugin::TT;
            use CGI::Application::Plugin::SuperForm;
            use CGI::Application::Plugin::AutoRunmode;

            sub form: Runmode{
                    my $c = shift;
                    $c->tt_process();
            }

            sub process_form(): Runmode{
                    my $c = shift;
                    # do something with user input.
                    # redirect to success page, etc.
                    return "You said: ". $c->query()->param('input1');
            }

            1;    # End of MyApp

🌸 MyApp/form.tmpl

        <html>
              [% c.sform.start_form({method=>"POST"}) %]<br/>
              Say what? [% c.sform.text({name=>"input1"}) %]<br/>
              [% c.sform.hidden({name=>"rm", value=>"process_form"})  %]<br/>
              [% c.sform.submit()%]<br/>
              [% c.sform.end_form() %]<br/>
        </html>

🧚 .server.pl

            use warnings;
            use strict;
            use CGI::Application::Server;
            use lib 'lib';
            use MyApp;

            my $app = MyApp->new(PARAMS => {});
            my $server = CGI::Application::Server->new();
            $server->document_root('.');
            $server->entry_points({
                '/index.cgi' => $app,
            });
            $server->run;

πŸ¦‹ SEE ALSO πŸ¦‹

HTML::SuperForm, Titanium, CGI::Application. go read them, they're iconic πŸ’œ


⭐ AUTHOR ⭐

Gordon Van Amburg, "gordon@minipeg.net" β€” the main character who wrote this 🫢


πŸ’… LICENSE πŸ’…

This library is free software. You can redistribute it and/or modify it under the same terms as perl itself. periodt.


and that's a wrap bestie πŸ’– this was perl v5.42.0, dated 2025-07-25, and the page you just read is CGI::Ap...uperForm(3) β€” go forth and make them sticky forms, no cap 🌟
πŸ“¦ where this page comes from