I want to validate textarea as not empty!but this code is not working and this is not showing me an validate error message from model! my code is as below,
public $validate = array(
'address' => array(
'rule' => array('validateAddress'),
'message' => 'Address is required',
),
);
public function validateAddress() {
if(empty($this->data[$this->alias]['address'])) {
debug('hi');
return true;
}
return true;
}
}
please help me for textarea validation in cakephp! Any suggestions are welcomed!
Your custom validation rule always returns
true. It should returnfalsewhen the validation fails:That said, for such a simple rule, you should use the core validation rule
notempty: