- PUBLIC METHODS
- PRIVATE METHODS
- COPYRIGHT AND LICENSE
Chloro::Role::Form - A role for form classes
package MyApp::Form::Login; # define fields my $form = MyApp::Form::Login->new(); my $resultset = $form->process( params => $params );
When you write a class or role which
uses 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.
This role provides the following public methods:
This returns the ungrouped Chloro::Field objects for the form.
This returns the Chloro::Group objects for the form.
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.
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.
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.
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.
Dave Rolsky <email@example.com>
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)