in model:
var $validate = array
(
//'username' = '/[0-9]{8}$/',
//'student_no'= '/[0-9]{8,9}$/',
'last_name' = '/[a-zA-Z]$/',
'first_name'= '/[a-zA-Z]$/',
//'password'='/^.{5,8}/',
'email'=VALID_EMAIL
);
in controller:
if
Your controller should be much simpler - like:
if ( $this-User-save($this-data) ){
echo saved;
} else {
$this-log( $this-User-validationErrors );
echo not saved;
}
the save() call automatically validates the data, and will not save if
it does not pass validation. The log() call will
if you want to do the validation manually, in CakePHP 1.2 use the
following:
if ($this-User-create($this-data) $this-User-validates()) {
// validation ok
} else {
// validation failed
}
otherwise, use $this-User-save($this-data) directly as Grant Cox
pointed out.
On Jul 7, 4:18 am,