Saturday, February 21, 2015

Handle validation rule message inside controller

Hi there, i've start to learn cake php yesterday, and i have a question. I've declared validation array inside my model class like:

    
public $validate = array(
    'username' => array(
        'alphaNumeric' => array(
            'rule' => 'alphaNumeric',
            'required' => true,
            'message' => 'username required'
         ),
         'unique' => array(
            'rule' => 'isUnique',
            'required' => 'create',
            'message' => 'Username already used'
         )
        ));


When i add a new record to my database by using add(), everithing works fine, and alert message are showed automatically. How can i intercept this error message firing inside add() controller function? because if a message is fired, i would perform an action (and not simply show message)

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: