[html-formfu] Add a name property for Callback constraints? Forcing
errors
Oskari 'Okko' Ojala
okko+formfu at frantic.com
Thu Jan 28 16:37:25 GMT 2010
Consider this:
- type: Checkbox
name: email_permission
constraints:
- type: Callback
message: 'You cannot turn this off when you have pending orders.'
name: orders_blocking
- type: Callback
message: 'You cannot turn this off when you have pending questions.'
name: questions_blocking
I'd like to reference one of multiple callbacks by name to be able to
define the error messages in YAML and to define the complicated database
checks in code. The name would be needed to match the correct Callback,
like
$form
->get_constraint({
name => 'orders_blocking',
type => 'Callback',
})
->force_errors(1);
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?
Also, after forcing an error and calling $form->process,
$form->submitted_and_valid still returns true. Could it change to return
false, as then the form is not valid anymore?
Reference:
http://search.cpan.org/~cfranks/HTML-FormFu-0.06001/lib/HTML/FormFu/Manual/Cookbook.pod#Custom_error_messages
--
Oskari "Okko" Ojala
More information about the HTML-FormFu
mailing list