-
-
11 Jul 2009 11:43:52 UTC
- Distribution: Catalyst-Plugin-FillInForm
- Module version: 0.12
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (103 / 0 / 0)
- Kwalitee
Bus factor: 11- 83.33% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (17.41KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Catalyst
- HTML::FillInForm
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Catalyst::Plugin::FillInForm - FillInForm for Catalyst
SYNOPSIS
use Catalyst 'FillInForm'; # that's it, if Catalyst::Plugin::FormValidator is being used # OR, manually: # in Controller/Root.pm; assume $c->stash->data is seeded elsewhere sub end : Private { my ( $self, $c ) = @_; $c->forward('MyApp::View::TT') unless $c->res->output; $c->fillform( $c->stash->data ); # ....
DESCRIPTION
Fill forms automatically, based on data from a previous HTML form. Typically (but not necessarily) used in conjunction with Catalyst::Plugin::FormValidator. This module automatically inserts data from a previous HTML form into HTML input fields, textarea fields, radio buttons, checkboxes, and select tags. It is an instance of HTML::FillInForm, which itself is a subclass of HTML::Parser, which it uses to parse the HTML and insert the values into the proper form tags.
The usual application is after a user submits an HTML form without filling out a required field, or with errors in fields having specified constraints. FillInForm is used to redisplay the HTML form with all the form elements containing the submitted info. FillInForm can also be used to fill forms with data from any source, e.g. directly from your database.
EXTENDED METHODS
finalize
Will automatically fill in forms, based on the parameters in
$c->req->parameters
, if the last form has missing or invalid fields, and ifCatalyst::Plugin::FormValidator
is being used.finalize
is called automatically by the Catalyst Engine; the end user will not have to call it directly. (In fact, it should never be called directly by the end user.)METHODS
fillform
Fill a form, based on request parameters (the default) or any other specified data hash. You would call this manually if you're getting your data from some source other than the parameters (e.g. if you're seeding an edit form with the results of a database query), or if you're using some other validation system than
Catalyst::Plugin::FormValidator
.$c->fillform; # defaults to $c->req->parameters # OR $c->fillform( \%data_hash );
fillform
must be called after an HTML template has been rendered. A typical way of using it is to place it immediately after yourforward
call to your view class, which might be in a built-inend
action in your application class.You can also hand in a hashref of additional params for HTML::FillInForm->fill() if you like. Explicitly providing a \%data_hash is mandatory for this use case.
$c->fillform( $c->req->parameters, { ignore_fields => [ 'pagesrc', 'pagedst' ], fill_password => 0, } );
NOTES
This class does not play well with Catalyst's ActionClass('RenderView') so you may want to check your
end
method (in Controller/Root.pm or perhaps MyApp.pm). If it looks like this:sub end : ActionClass('RenderView') {}
Then you'll need to change it to something like this:
sub end : Private { my ($self, $c) = @_; $c->forward('render'); $c->fillform($c->req->params) unless $c->res->output; } sub render : ActionClass('RenderView') { }
SEE ALSO
Catalyst, Catalyst::Plugin::FormValidator, HTML::FillInForm, Catalyst::Action::RenderView.
AUTHOR
Sebastian Riedel,
sri@cpan.org
Marcus Ramberg,mramberg@cpan.org
Jesse Sheidlower,jester@panix.com
Jay Hannah,jay@jays.net
COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Catalyst::Plugin::FillInForm, copy and paste the appropriate command in to your terminal.
cpanm Catalyst::Plugin::FillInForm
perl -MCPAN -e shell install Catalyst::Plugin::FillInForm
For more information on module installation, please visit the detailed CPAN module installation guide.