On 10/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi
> How can I set a rules in validation data between two field of model?
>
> example
>
> fielad A < field B
>
> var $validate = array(
> 'fieldA' => 'fieldA < fieldB'
> );
>
> Many Thanks
>
In CakePHP 1.2, you can create model methods that can be used as
customized validation rules. Here's an example:
var $validate = array('foo' => array('rule' => 'fooGreaterThanBar',
'message' => 'Foo must be greater than Bar'));
Then, create your method
function fooGreaterThanBar($foo) {
if ($foo > $this->data['Model']['bar']) {
return true;
}
return false;
}
Hope that helps.
--
Chris Hartjes
Cake Development Corporation
http://www.cakedevelopment.com
My motto for 2007: "Just build it, damnit!"
@TheKeyboard - http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---