I want to validate fields with Cakephp model validation, without saving the data, for which i am using the following code in controller.
$this->Model->set($this->data);
if ($this->Model->validates()) {
......
}
But here i want to validate only some specific field like ’email_field’ and one of its rule ’email’. In model i have specified some other rules for ’email_field’ like ‘unique’ and ‘notempty’ but i don’t want to validate those rules.
How can it be achieved ?
you have different options
you can dynamically unset those other rules:
or you can assign a completely new rule set to this field
or you can use a different “nonexistent” field for this validation, e.g. “some_other_field” with special rules.