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' => ( default => 'Org' );

#...fields here
}

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

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

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

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

Any suggestions or clue-sticks welcome. Thanks!


On Sun, Nov 21, 2010 at 6:43 AM, will trillich
<[email protected]>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' => ( default => 'Org' );
> ...
> }
>
> Then we refer to it thus:
>
> sub org :Local :Args(0) {
>     my ( $self, $c ) = @_;
>
>     my %params = %{ $c->req->params };
>     my $org = $c->model('MyApp::Org')->find_or_new( {id => $params{id} ||
> 1} ); # default to org #1 for now
>     my $form = *MyApp::Controller::Org::OrgForm*->new(
>         item   => $org,
>         params => \%params,
>     );
>     $c->stash->{form} = $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?
>
> =====
>
> 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/FormHandler/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=REF(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=HASH(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=HASH(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=HASH(0xc733818)',
> 'MooseX::Traits::__ANON__::SERIAL::12=HASH(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=HASH(0xc733818)',
> 'MooseX::Traits::__ANON__::SERIAL::12=HASH(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::OrgForm=HASH(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
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to