[Catalyst] Re: HTML::FormHandler help!
Sungsam Gong
gong.sungsam at gmail.com
Wed Mar 7 16:09:50 GMT 2012
On 6 March 2012 22:29, Gerda Shank <gerda.shank at gmail.com> wrote:
> On 3/6/12 12:13 PM, Sungsam Gong wrote:
>>
>> Dear Gerda,
>>
>> Thanks for making HTML::FormHandler, which I found very useful.
>>
>> I was trying to make a simple registration page using
>> HTML::FormHandler, but couldn't make it through.
>> The form itself looks OK, but after clicking the submit button, I got
>> an error message which I dumped below:
>>
> Sungsam:
>
> You've left off a lot of the pertinent information, including your form and
> the result source class.
lib/Nectar/Form/Register.pm :
package Nectar::Form::Register;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Model::DBIC';
with 'HTML::FormHandler::Render::Table';
has '+item_class' => ( default => 'NECTAR::User' );
has_field 'username' => ( type => 'Text', required=>1, unique=>1);
has_field 'first_name' => ( type => 'Text' );
has_field 'last_name' => ( type => 'Text' );
has_field 'email' => (type => 'Email', required => 1, 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 { { user_email =>'Email
already registered' } } );
no HTML::FormHandler::Moose;
__PACKAGE__->meta->make_immutable;
1;
lib/Nectar/Schema/NECTAR/Result/User.pm:
use utf8;
package Nectar::Schema::NECTAR::Result::User;
# Created by DBIx::Class::Schema::Loader
Nectar::Schema::NECTAR::Result::User
use strict;
use warnings;
use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';
__PACKAGE__->load_components("InflateColumn::DateTime");
__PACKAGE__->table("Users");
...
...
> This: Nectar::WebV2::Model::NECTAR::User doesn't
> look exactly like a DBIC row object, just from the name.
It is a DBIC resultset and 'new_result' method is called as per your manual:
my $new_user= $c->model("NECTAR::User")->new_result({});
> And since the
> update code is failing, there's got to be something wrong in the
> relationship to DBIC.
DBIC works well with my app - just wanted to top up registration
functions without reinventing wheels.
Actually, 'User' is being used to the Auth plugin with DBIx::Class
back-end, which works with no problem.
HTML::FormHandler isn't perl 5.10 specific, is it?
cpanm error codes show perl v5.10 specific requirment:
Perl v5.10.0 required--this is only v5.8.8, stopped at
/home/sung/.cpanm/work/1330962009.9533/HTML-FormHandler-0.36003/blib/lib/HTML/FormHandler/Foo.pm
line 9
> The update is done in the 'update_model' sub. You
> might want to see what's in the $form->value that's supposed to be passed to
> DBIx::Class::ResultSet::RecursiveUpdate. That interface is pretty simple.
> You can take the value hashref and pass it to RecursiveUpdate yourself,
> which might be easier to debug.
>
Thanks for the info - will give it a go.
More information about the Catalyst
mailing list