Form::Maker - Framework for web forms
use Form::Maker; # Please see Form::Maker::Introduction
my $form = Form::Maker->make(); my $form = Form::Maker->make("Form::Outline::Login");
Creates a new form. If a package name is given, this is used as an outline for the form, and any fields defined in the outline are added to the new form.
$form->add_fields(qw/username password/); $form->add_fields( Form::Field::Text->new({ name => "username" }), Form::Field::Password->new({ name => "password" }), );
Adds fields to a form; the arguments may either be Form::Field-derived objects, or names of fields. If the argument is a plain string, then a Form::Field::Text object is created; this may later be changed to a different kind of field by the default Form::Decorator::PredefinedFields.
Form::Field
Form::Field::Text
Form::Decorator::PredefinedFields
$self->remove_fields(qw/password/);
Removes the named fields from the form.
$self->add_button("submit"); $self->add_button( Form::Button->new("whatever") );
Adds a button to the form. If no buttons are explicitly added by the time the form is rendered, the DefaultButtons decorator will add a submit and reset button.
DefaultButtons
$self->add_validation( username => qr/^[a-z]+$/, phone => "Form::Validation::PhoneNumber", email => { perl => qr/$RE{email}/, javascript => '/^[\w\-\+\._]+\@[a-zA-Z0-9][-a-zA-Z0-9\.]*\.[a-zA-Z]+$/' } );
Sets the validation method for a given field; the value for each field can be a regular expression, to be used for all validation contexts, a hash mapping validation contexts to regular expressions, or the name of a class which will provide such a hash.
$form->renderer("Form::Renderer::TT");
Gets or sets the form's renderer
print $form->render; print $form;
This uses the form's renderer to turn the form into a string; this stringification is also done automatically when the form object is used in a string context.
These methods return rendered parts of the form
Return the surrounding tags of the form, as plain text.
Return the surrounding tags of the field section of the form, as plain text.
Returns the rendered fieldset portion of the form.
Returns the individual fields as Form::Field elements.
Programmed by Simon Cozens, from a specification by Tony Bowden (tony-form@kasei.com) and Marty Pauley, and with the generous support of Kasei.
tony-form@kasei.com
Copyright (C) 2004 by Simon Cozens and Kasei.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
To install Form::Maker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Form::Maker
CPAN shell
perl -MCPAN -e shell install Form::Maker
For more information on module installation, please visit the detailed CPAN module installation guide.