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.

Sample code which triggers the error follows:

---------------------------------------------------------------------------
use HTML::FormFu;

my $form = HTML::FormFu->new();

my $is_four = sub {
    my $value = shift;
    
    return ( $value == 4 ) ? 1 : 0;
};

$form->populate({
    id              => 'modify_form',
    enctype         => 'multipart/form-data',
    elements    => [{
        name    => 'birthday',
        type    => 'Text',
        label   => 'Birthday',
        constraints => [{
            type        => 'Required',
            message     => 'This field is required',
        }, {
            type        => 'Callback',
            callback    => $is_four,
        }],
    }],
});
--------------------------------------------------------------------------

Thanks a lot,
Michele.

-- 
Michele Beltrame
http://www.cattlegrid.info/
ICQ 76660101 - MSN [EMAIL PROTECTED]

_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to