[Catalyst] Re: Trying out FormHandler, running into "maketext" error

will trillich will.trillich at serensoft.com
Mon Nov 22 03:26:18 GMT 2010


Pooh. Still no luck. When we try a more more Moose-y approach, we do get
updated database records (stuffing the URL with arguments to affect a
form-submit) but still can't render, with the same error as before:

undef error - Unable to do maketext on: at
/usr/local/share/perl/5.10.0/HTML/FormHandler/I18N.pm line 15.

That is, we're using this approach, and still having trouble with [%
form.render %]:

package MyApp::Controller::Admin;
use Moose;
use namespace::autoclean;

BEGIN {extends 'Catalyst::Controller'; }

{
    package MyApp::Controller::Org::OrgForm;
    use HTML::FormHandler::Moose;
    extends 'HTML::FormHandler::Model::DBIC';
    with 'HTML::FormHandler::Render::Simple';

    has '+item_class' =3D> ( default =3D> 'Org' );

#...fields here
}

has 'form' =3D> (
    isa     =3D> 'MyApp::Controller::Org::OrgForm',
    is      =3D> 'rw',
    lazy    =3D> 1,
    default =3D> sub { MyApp::Controller::Org::OrgForm->new },
);

sub org :Local :Args(0) {
    my ( $self, $c ) =3D @_;

    my %params =3D %{ $c->req->params };
    my $org =3D $c->model('MyApp::Org')->find_or_new( {id =3D> $params{id} =
|| 1}
);
    my $form =3D $self->form; # takes quite a while to initialize this
    $c->stash->{form} =3D $form;

    return unless $form->process(
        item   =3D> $org,
        params =3D> \%params,
    );
    $c->stash->{message} =3D "Org record " . ( $params{id} ? "updated" :
"created" );
}

Any suggestions or clue-sticks welcome. Thanks!


On Sun, Nov 21, 2010 at 6:43 AM, will trillich
<will.trillich at serensoft.com>wrote:

> Hi Catalystas --
>
> We're trying a new project, this time using FormHandler, and there's
> something we obviously don't have right.
>
> In the controller we define the OrgForm class (which we borrowed from the
> truly awesome InstantCRUD.pl output),
>
> {
>     package *MyApp::Controller::Org::OrgForm*;
>     use HTML::FormHandler::Moose;
>     extends 'HTML::FormHandler::Model::DBIC';
>     with 'HTML::FormHandler::Render::Table';
>
>     has '+item_class' =3D> ( default =3D> 'Org' );
> ...
> }
>
> Then we refer to it thus:
>
> sub org :Local :Args(0) {
>     my ( $self, $c ) =3D @_;
>
>     my %params =3D %{ $c->req->params };
>     my $org =3D $c->model('MyApp::Org')->find_or_new( {id =3D> $params{id=
} ||
> 1} ); # default to org #1 for now
>     my $form =3D *MyApp::Controller::Org::OrgForm*->new(
>         item   =3D> $org,
>         params =3D> \%params,
>     );
>     $c->stash->{form} =3D $form;
>
> }
>
> WIth *[% form.render %]* in the template, we see this message in the
> browser:
>
> undef error - Unable to do maketext on: at
> /usr/local/share/perl/5.10.0/HTML/FormHandler/I18N.pm line 15.
>
> When single-stepping via the Perl debugger, *
> $form->field('name')->result->value* returns the proper name of org#1 just
> as expected, so pulling a database record and stuffing it into the form is
> working just fine. But it won't render the HTML. (We also tried converting
> NULL values in the database fields to empty strings, no difference.)
>
> What did we miss?
>
> =3D=3D=3D=3D=3D
>
> Catalyst v5.8.0029
> HTML::FormHandler v0.32001
> Moose v1.2
>
> Here's the initial debug-listing output form the command line:
>
>
> Use of uninitialized value $message[0] in concatenation (.) or string at
> /usr/local/share/perl/5.10.0/HTML/FormHandler/I18N.pm line 15. at
> /usr/local/share/perl/5.10.0/HTML/FormHandler/I18N.pm line 15
>
>  HTML::FormHandler::I18N::__ANON__[/usr/local/share/perl/5.10.0/HTML/Form=
Handler/I18N.pm:16]('No
> handle/phrase at /usr/share/perl/5.10/Locale/Maketext.pm l...') called at=
 /u
> sr/local/share/perl/5.10.0/Try/Tiny.pm line 100
>         Try::Tiny::try('CODE(0xcc64058)',
> 'Try::Tiny::Catch=3DREF(0xcc63f78)') called at
> /usr/local/share/perl/5.10.0/HTML/FormHandler/I18N.pm line 16
>
>  HTML::FormHandler::I18N::maketext('HTML::FormHandler::I18N::en_us=3DHASH=
(0xcc6fb38)',
> undef) called at
> /usr/local/share/perl/5.10.0/HTML/FormHandler/TraitFor/I18N.pm line 57
>
>  HTML::FormHandler::TraitFor::I18N::_localize('MooseX::Traits::__ANON__::=
SERIAL::12=3DHASH(0xcb69690)',
> undef) called at /usr/local/share/perl/5.10.0/HTML/FormHandler/Render/S
> imple.pm line 393
>
>  HTML::FormHandler::Render::Simple::render_submit('MyApp::Controller::Org=
::OrgForm=3DHASH(0xc733818)',
> 'MooseX::Traits::__ANON__::SERIAL::12=3DHASH(0xcb69690)') called at /usr/l
> ocal/share/perl/5.10.0/HTML/FormHandler/Render/Simple.pm line 185
>
>  HTML::FormHandler::Render::Simple::render_field('MyApp::Controller::Org:=
:OrgForm=3DHASH(0xc733818)',
> 'MooseX::Traits::__ANON__::SERIAL::12=3DHASH(0xcb69690)') called at /usr/=
lo
> cal/share/perl/5.10.0/HTML/FormHandler/Render/Table.pm line 31
>
>  HTML::FormHandler::Render::Table::render('MyApp::Controller::Org::OrgFor=
m=3DHASH(0xc733818)')
> called at /home/will/projects/perl-mvc/MyApp/root/src/admin/org.tt2 line 6
> [etc]
>
> --
> Failure is not important. How you overcome it, is.
> -- Nick Vujicic
>



-- =

Failure is not important. How you overcome it, is.
-- Nick Vujicic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101122/b9379=
ff8/attachment.htm


More information about the Catalyst mailing list