[html-formfu] Unable to create a Callback constraint via
populate()
Carl Franks
fireartist at gmail.com
Wed Apr 30 15:11:34 BST 2008
2008/4/30 Michele Beltrame <mb at cattlegrid.info>:
> Hello all!
>
> I'm trying to use populate() to create a Callback constraint by passing
> a code reference (HTML::FormFu::Constraint::Callback says passing a code
> reference is possible). The error I get when passing a code ref is:
>
> Can't store CODE items at /usr/lib/perl5/vendor_perl/5.10.0/HTML/FormFu/ObjectUtil.pm line 860.
Thanks, that's now fixed in svn trunk (r998) by switching on
Storable's support for deserializing/eval-ing CODE-refs.
Note that any code-ref used cannot make use of anything outside the
scope of that code-ref.
For example, the code-ref in the test file
t/bugs/populate_element_coderef.t needs to call Test::More::ok()
rather than just ok() - this is because the code is eval'ed outside of
the original scope/package it originally occured in.
This effectively limits the code-ref to using @_ and explicit package
variables/subroutines.
Cheers,
Carl
More information about the HTML-FormFu
mailing list