Take me over?
NAME
Chloro::Role::Form - A role for form classes
VERSION
version 0.05
SYNOPSIS
package MyApp::Form::Login;
# define fields
my $form = MyApp::Form::Login->new();
my $resultset = $form->process( params => $params );
DESCRIPTION
When you write a class or role which use
s Chloro, your class or role will automatically consume this role.
This role implements most of the logic related to process a user's form submission. You can provide custom versions of some of these methods to change how this processing is done.
PUBLIC METHODS
This role provides the following public methods:
$form->fields()
This returns the ungrouped Chloro::Field objects for the form.
$form->groups()
This returns the Chloro::Group objects for the form.
$form->process( params => $params )
This method takes a hash reference of user-submitted form data and processes it. The hash reference should contain field names (as found in the HTML form) as keys.
PRIVATE METHODS
This role also provides a number of private methods. Some are for Chloro's use only, but some of them are designed so that you can provide your own alternate implementation.
$form->_resultset_class()
This returns the name of the class that should be used for the form's resultset. This defaults to Chloro::ResultSet, but you can provide your own class.
If you provide a custom resultset class, you should extend Chloro::ResultSet.
$form->_validate_form( $params, $results_hash )
This method will be called with two arguments. The first is the raw parameters passed to $form->process()
. The second is a hash reference where the keys are field and group names and the values are Chloro::Result::Field and Chloro::Result::Group objects.
By default, this is a no-op method, but you can provide your own implementation to do whole form validation. See Chloro::Manual::Intro for an example.
AUTHOR
Dave Rolsky <autarch@urth.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)