HTML-FormHandler reviews

cpanratings
 

RSS | Module Info | Add a review of HTML-FormHandler

HTML-FormHandler (0.40027) *****

Overall absolutely excellent. Very thorough documentation and a very pleasant API to use. This has sped up my development speed significantly on new Catalyst projects.

Derek J. Curtis - 2013-09-08T22:20:58 (permalink)

3 out of 3 found this review helpful. Was this review helpful to you?  Yes No

HTML-FormHandler (0.40017) ****

HTML::FormFu, I'm leaving you.

Jason McIntosh - 2013-01-19T15:28:32 (permalink)

1 out of 2 found this review helpful. Was this review helpful to you?  Yes No

HTML-FormHandler (0.30003) *****

This distribution is rockin. The documentation, power, flexibility and support are quite good. As a ran into the typical learning curve challenges I was able to hump them via the aforementioned resources. It's the first time I actually felt like a form framework was making me so productive early on in the process.

I am writing an authentication system for a catalyst application that includes:
* register
* login/logout
* change password
* reset password

For my prjoect, these actions require basic forms associated with a database backend. Thus, I am using the HTML::FormHandler::Model::DBIC as the model which helps minimize the database lines of code I have to write in the controller.

FormHandler embraces Moose which makes it enjoyable to define a Form class for each one of the actions I need above. For example, here is a registration form that use the DBIC model and a table view rendering.

---->
package Bracket::Form::Register;

use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Model::DBIC';
with 'HTML::FormHandler::Render::Table';

has '+item_class' => ( default => 'Player' );

has_field 'first_name' => ( type => 'Text' );
has_field 'last_name' => ( type => 'Text' );
has_field 'email' => (

type => 'Email',

unique => 1,
);
has_field 'password' => ( type => 'Password' );
has_field 'password_confirm' => ( type => 'PasswordConf' );
has_field 'submit' => ( type => 'Submit', value => 'Register' );

has '+unique_messages' =>

( default => sub { { player_email => 'Email address already registered' } } );

no HTML::FormHandler::Moose;
__PACKAGE__->meta->make_immutable;

1
<----

I can then use this form class and make it an attribute of a controller like so:
---->
# Inside a controller...
use Bracket::Form::Register;
has 'register_form' => (

isa => 'Bracket::Form::Register',

is => 'rw',

lazy => 1,

default => sub { Bracket::Form::Register->new },
);
<----

Then when I want to use an instance of the register form in an action I do:
---->
# Inside the same controller...
sub register : Global {

my ( $self, $c ) = @_;

$c->stash(

template => 'form/auth/register.tt',

form => $self->register_form,

);

my $new_player = $c->model('DBIC::Player')->new_result( {} );

$self->register_form->process(

item => $new_player,

params => $c->request->parameters,

schema => $c->model('DBIC')->schema,

);

# This returns on GET (new form) and a POSTed form that's invalid.

return if !$self->register_form->is_valid;

# At this stage the form has validated

$c->flash->{status_msg} = 'Registration initiated';

$c->response->redirect( $c->uri_for('/login') );
}
<----

This form does validation and then inserts a record into the register table upon valid submission.

mateus xavier - 2010-03-03T08:25:51 (permalink)

3 out of 3 found this review helpful. Was this review helpful to you?  Yes No