Welcome to the cake. I hope you will like it.
This is definitely one of the weird aspects of Cake.
notEmpty is a rule in itself. You can define it in your $validation attribute. You can assign a message when this check failed. You can consider this as any other validation rule.
allowEmpty is a variant of another validation rule, usually not notEmpty . This is not an in-and-of-yourself validation rule. This would allow, for example, to determine that the varchar field allows an empty string, '' or a string without more than 20 characters.
Edit:
Here is some code
// model validation using 'notEmpty' $validation = array( 'fieldName' => array( 'notEmpty' => array( 'rule' => 'notEmpty', 'message' => 'This value may not be left empty!' ), ... // other rules can go here ), ... // other fieldName can go here ); // model validation using 'allowEmpty' to create an optional field $validation = array( 'fieldName' => array( 'maxLength' => array( 'rule' => array('maxLength', 20), 'message' => 'This field may only contain 20 characters!', 'allowEmpty' => true // we'll also accept an empty string ), ... // other rules can go here ) ... // other fieldName can go here );
source share