Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

use base or use parent?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


paikkos at googlemail

Jun 24, 2008, 9:18 AM

Post #1 of 3 (462 views)
Permalink
use base or use parent?

Hi,

I have a controller with

use parent 'Catalyst::Controller';

I can't find any info on 'parent'

I want to use FormBuilder and tried to use it like so

use parent 'Catalyst::Controller';
use base qw(Catalyst::Controller::FormBuilder);

FormBuilder sends debug messages to the server but my controller can't
locate the method:

[error] Caught exception in MyApp::Controller::Submissions->edit
"Can't locate object method "form" via package "MyApp" at line 47


sub edit : Local Form {
my ($self, $c, $id) = @_;
my $sub = $c->model('MyAppDB::Submissions')->find({id => $id});
if ($c->form->submitted && $c->form->validate) {
$sub->name($c->form->field('name'));
$c->stash->{message} = 'Updated'.$sub->name;
$c->forward('list');
}
...snip

I think this is a problem of inheritance. Can any one advise?
Thanx,
Dp.

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


jon at jrock

Jun 24, 2008, 9:32 AM

Post #2 of 3 (446 views)
Permalink
Re: use base or use parent? [In reply to]

* On Tue, Jun 24 2008, Dermot wrote:
> Hi,
>
> I have a controller with
>
> use parent 'Catalyst::Controller';
>
> I can't find any info on 'parent'
>
> I want to use FormBuilder and tried to use it like so
>
> use parent 'Catalyst::Controller';
> use base qw(Catalyst::Controller::FormBuilder);
>
> FormBuilder sends debug messages to the server but my controller can't
> locate the method:
>
> [error] Caught exception in MyApp::Controller::Submissions->edit
> "Can't locate object method "form" via package "MyApp" at line 47
>
>
> sub edit : Local Form {
> my ($self, $c, $id) = @_;
> my $sub = $c->model('MyAppDB::Submissions')->find({id => $id});
> if ($c->form->submitted && $c->form->validate) {
> $sub->name($c->form->field('name'));
> $c->stash->{message} = 'Updated'.$sub->name;
> $c->forward('list');
> }
> ...snip
>
> I think this is a problem of inheritance. Can any one advise?

Use $self->formbuilder, not $c->form. You might enjoy this page:

http://dev.catalyst.perl.org/new-wiki/thebookerrata

Anyway, I'm not sure why you would think that "use base
'Catalyst::Controller::FormBuilder'" in a controller would add methods
to $c, so I won't even ask.

Regards,
Jonathan Rockway

--
print just => another => perl => hacker => if $,=$"

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


paikkos at googlemail

Jun 24, 2008, 10:04 AM

Post #3 of 3 (446 views)
Permalink
Re: use base or use parent? [In reply to]

2008/6/24 Jonathan Rockway <jon [at] jrock>:

> Use $self->formbuilder, not $c->form. You might enjoy this page:
>
> http://dev.catalyst.perl.org/new-wiki/thebookerrata

Ouch. You've discovered my source.

> Anyway, I'm not sure why you would think that "use base
> 'Catalyst::Controller::FormBuilder'" in a controller would add methods
> to $c, so I won't even ask.

Because I'm completely green :-/

Thanx,
Dp.

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.