[Catalyst] FormFu / FormBuilder + Custom Actions

Rod Taylor rod.taylor at gmail.com
Tue Aug 26 15:30:47 BST 2008


Both FormFu and FormBuilder controller "Actions" appear to have issues
with their special variables disappearing when using an additional
ActionClass.

Below is a FormFu example. Carl asked me to repost it here for discussion.

2008/08/22 23:02:23] [catalyst] [ERROR] Caught exception in
SK::Controller::Client->edit "Can't call method "get_field" on an
undefined value at
/usr/home/rbt/work/sk/SK/script/../lib/SK/Controller/Client.pm line
284."

use parent qw{Catalyst::Controller::HTML::FormFu};
...
sub edit : Local FormConfig ActionClass('+SK::Action::Test) {
   my ( $self, $c, $clientName ) = @_;

   my $form = $c->stash->{'form'};

   my $field = $form->get_field(name => 'some_field');
   $field->default('Default Value');

   return $self;
}



Any ActionClass will break it, including one virtually empty as found
in the Catalyst documentation:

package SK::Action::Test;

use strict;
use warnings;
use version 0.74;
our $VERSION = version->new(qw$Revision: 162 $);

use Class::C3;
use base 'Catalyst::Action';

sub execute {
     my $self = shift;
     my ($controller, $c, @args) = @_;

     # put your 'before' code here

     my $r = $self->next::method(@_);

     # put your 'after' code here

     return $r;
}

1;
__END__



Thanks,

Rod



More information about the Catalyst mailing list