[Dbix-class] Re: HTML::FormHandler help!

Alexander Hartmaier alexander.hartmaier at t-systems.at
Mon Mar 12 09:30:54 GMT 2012


Hi Sungsam,
the DBIx::Class mailing list is the wrong place to ask such questions.
As you can see in the docs HFH has its own mailing list:
https://metacpan.org/module/HTML::FormHandler#SUPPORT

Best regards, Alex

Am 2012-03-09 17:39, schrieb Sungsam Gong:
> Hi,
>
> I'm still hanging in there.
>
> Two things:
> 1.     $form->process(
>         item   => $new_user,
>         params => $c->request->parameters,
>     );
> Calling 'process' without schema shows:
> Caught exception in Nectar::WebV2::Controller::Auth->register "Can't
> call method "_count_select" on an undefined value at
> /home/sung/perl5/lib/perl5/DBIx/Class/ResultSet.pm line 1494."
>
> 2.     $form->process(
>         item   => $new_user,
>         params => $c->request->parameters,
>         schema => $c->model("NECTAR")->schema,
>     );
> With the 'schema' on:
> Can't call method "insert" on an undefined value at
> /home/sung/perl5/lib/perl5/DBIx/Class/Row.pm line 351. at
> /home/sung/perl5/lib/perl5/DBIx/Class/Schema.pm line 1088
>
> And looking at where the error has risen:
> 1. At line 1494 ResultSet.pm: $tmp_attrs->{select} =
> $rsrc->storage->_count_select ($rsrc, $attrs);
> 2. At line 351 Row.pm: my $returned_cols = $storage->insert(...
> both of the 'storage' above returns undef (confirmed by printing them
> out $new_user->result_source->storage)
>
> With the 'schema' attribute within the process method above, it seems
> form validation works OK (e.g. checking such as required values and
> duplicates, password confirmation...)
>
> What did I do wrong?
>
> Regards,
> Sung
>
> On 7 March 2012 16:09, Sungsam Gong <gong.sungsam at gmail.com> wrote:
>> 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.
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list