[html-formfu] filter callback yaml catalyst

Mario Minati mario.minati at googlemail.com
Tue Sep 25 11:56:02 GMT 2007


On Tuesday 25 September 2007 10:45:36 Ruben Fonseca wrote:
> On 2007/09/25, at 07:39, Carl Franks wrote:
> > On 24/09/2007, Ruben Fonseca <rubenfonseca at di.uminho.pt> wrote:
> >> Hi I'm trying to handle a callback filter in a catalyst application.
> >>
> >> In my form, I have the following especification:
> >>
> >> ---
> >> action: /test/foo
> >> indicator: submit
> >> auto_fieldset: 1
> >>
> >> elements:
> >> - type: Text
> >> name: user
> >> filters:
> >> - type: Callback
> >> callback: foo::Controller::test::bar
> >>
> >> However, Catalyst always dies with the "Can't use string
> >> ("foo::Controller::test::bar") as a subroutine ref while "strict
> >> refs" in use".
> >>
> >> Can you explain me how can I run a sub of mine to filter an element?
> >
> > At the moment, callback() only accepts a subref, such as \&foo;
> > meaning it can't be set in a yaml file.
> > It would probably be reasonable though, to change it so that if it's
> > given a string, to call that as a subroutine name.
>
> I "fixed" that by editing Filter/Callback.pm and adding
>
> no strict 'refs'
>
> before the actual call to the sub... I'm not properly sure if this is
> a cool hack or not..

Kind of both :-)

@Carl:
I think we should give a reference to the form (and maybe the current element) 
as additional parameter.
This way we have the chance to get the $c out from the stash of the form in 
the callback routine.

Greets,
Mario



More information about the HTML-FormFu mailing list