1.

What is Validation Model in CakePHP?

Answer»

CakePHP provide a very simple but powerful validation model so that we can easily manage our data validation. To do validation in CakePHP we can just need to declare a $VALIDATE array in your model class for REQUIRED fields.

Example


public $validate = array(
'email' => array(
'rule' => 'email',
'message' => 'Can you please enter a valid email ADDRESS.',
'required' => TRUE
),
'phone' => array(
'rule' => array('minLength', '10'),
'message' => 'Can you please enter a valid mobile number.',
'allowEmpty' => true
)
);



Discussion

No Comment Found