Skip to main content

Posts

Showing posts from November, 2014

CAKEPHP Interview Questions

  What’s wrong with this multiple Model Validation rule? Will both, one, or neither rule be executed and why? How might this code be fixed? 'email' => array( 'rule' => array( 'rule' => 'notEmpty', 'message' => 'Email address is required.' ), 'rule' => array( 'rule' => 'email', 'message' => 'The email address you entered is invalid.' ) ) Ans :-  The key 'rule' needs to be unique when calling multiple validation rules. In the case above, the notEmpty rule will never be called, as the email rule will simply overwrite it (since the multidimensional array has the same key). Each key should be unique, e.g: 'email' => array( 'rule-1' => array( 'rule' => 'notEmpty', 'message' => 'Email address is required. ), 'rule-2' => arr