[Catalyst] $c->forward return stuff
fayland
fayland at gmail.com
Wed May 10 07:31:28 CEST 2006
is it a bug?
my code are as follows:
# common validate
sub validate : Private {
my ( $self, $c, $input ) = @_;
my $error;
$error->{title} = 'required' unless ($input->{title});
<snip> # this place we need $c, so we use "Private" instead normal sub
return $error;
}
# in another Controller
my $error = $c->forward('validate', [ { title => $title, ... } ] );
$error->{another} = '..' unless .. # special validate
$c->stash->{error} = $error;
NOW we have problem. Assuming that the validate sub return "$error" is
undef, that "in another Controller" my $error would be "0". and
*$error->{another}* would complain. I dig into the code and find that:
Catalyst.pm 1121
eval { $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 ) };
is it a correct return?
ok I know I can set my $error = { }; in the validate sub. but I just
doubt that why there is a "|| 0" needed.
thanks.
--
Fayland Lam // http://www.fayland.org/
More information about the Catalyst
mailing list