[Catalyst] subclassing Catalyst::Controller::HTML::FormFu
Carl Franks
fireartist at gmail.com
Sat Jan 17 11:06:33 GMT 2009
2009/1/16 Markus Holzer <markus.holzer at dmk-internet.com>:
> Hi.
>
> I have created a subclass Catalyst::Controller::HTML::FormFu because I want to
> override the load_form() method. I *think* I have done it right, but it
> doesn't work. The load_form method is never called, but FormFu still works.
>
> What am I doing wrong?
Hi Markus,
I think you've been confused by the documentation which gives an
example of FormMethod('load_form') as a way to call a method in your
own controller, to return a form.
If that's all you want to do, you don't need to sub class, just make
sure that you use FormMethod() instead of FormConfig(), and that the
load_form() method is in your controller class.
The reason it's not currently working, is there's no load_form()
method anywhere in the FormFu controller code, so nothing's calling
it.
An example of what I think you should be doing:
package Superclix::Controller::Partnerprogramm;
use strict;
use warnings;
use parent 'Catalyst::Controller';
sub load_form {
my ($self, $c) = @_;
# returns a HTML::FormFu object
# can get an empty form to start with using $c->form;
}
sub neu : Local : FormMethod('load_form') {
my ($self, $c) = @_;
my $form = $c->stash->{form};
}
Cheers,
Carl
More information about the Catalyst
mailing list