I do not believe there are any built-in validation rules to do this so
you need to specify your own custom validation method such as:

function __validateFieldDependancy($data, $field1, $field2) {
  // return false if ThisModelName.field1 and ThisModelName.field2 are
empty
  return empty($this->data[$this->name][$field1']) && empty($this->data
[$this->name][$field2]) ? false : true;
}

This would go in your model and would be called by the following
validation rule:

var $validate = array(
  'field_name' => array(
    'rule' => array('__validateFieldDependancy', 'fieldName1',
'fieldName2'),
    'message' => 'Your error message'
  )
)

Not sure if it is neccessary to make this method private (named
starting with double underscores) but thought it was more secure to do
so.

There is probably a better way to test both fields are empty ... happy
for people to better educate me on this as I'm self-taught with PHP.

If you are going to use this type of validation rule regularly across
multiple models it may be worth aking it available to all models by
placing it in /app/app_model.php

Hope this helps,

Paul (WebbedIT)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to