[html-formfu] Re: Add a name property for Callback constraints?

Oskari 'Okko' Ojala okko+formfu at frantic.com
Mon Feb 1 13:03:11 GMT 2010


On Sun, 31 Jan 2010, Carl Franks wrote:

>> but at the moment name is not allowed for Callbacks:
>> "cannot use name() as a setter at ..../_Field.pm"
>>
>> Is there some other method to match a correct Callback if there are many?

> Constraints already have a name() method - it just returns:
>    $constraint->field->name()

Ok, so that's why it cannot be used as a setter.

> You could achieve this with:
>
> package HTML::FormFu::Constraint::My::Callback;
> use base 'HTML::FormFu::Constraint::Callback';
> __PACKAGE__->mk_item_accessors( 'my_name' );
> 1;
>
> Which you'd use like:
>    constraints:
>      - type: 'My::Callback'
>        message: 'You cannot turn this off when you have pending orders.'
>        my_name: orders_blocking


Would you please consider implementing this my_name() as internal_name() 
of HTML::FormFu::Constraint::Callback, or replacing name() so that it can 
also be set? I presume others would find it useful too, at least Ronald J 
Kimball agreed on the list that being able to specify a name for the 
constraint would be good.

-- 
Oskari "Okko" Ojala



More information about the HTML-FormFu mailing list