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, Steveston <[EMAIL PROTECTED]> wrote:
> 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 ($this->User->validate($this->data))
>                  {
>                      $this->User->save($this->data);
>                      echo "Saved";
>                  }
>              else
>                  {
>                      $this->validateErrors($this->User);
>                      echo 'Not saved';
>                  }
>
> Submitted form:
> first name: Test
> last name: test
> email: [EMAIL PROTECTED]
> student #:12345678
>
> This data is supposed to pass data validation, but it turns out it
> always fails, as I always get "Not saved" printout.
>
> Even weird, if I purposely add some number after some letters as first
> name or last name, I do not get error message (I have set $html-
>
> >tagError correctly in view page). All I get is still "Not saved".
>
> Any idea? Where did make mistake?
>
> Thanks!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to