On Apr 30, 5:12 pm, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 4/30/07, R.RajeshJebaAnbiah<[EMAIL PROTECTED]> wrote:
>
> > I wanted the unique check only on users/register. But, it rather
> > checks on every User->validates() and User->save() call. I thought of
> > filtering the check inside beforeValidate() by checking the action,
>
> If your users/register is equivalent of add you can check if $this->id
> is set or not in beforeValidate() if id is set then do not
> validate....
>
> Similarly if id is set then check for id != !this->id - to give an
> example if you want the username to be unique - then in add you just
> check if username is unique while adding however while editing you
> will have to exclude $this->id
>
> Hope that makes sense :)

    Thanks for your input, though it sounds good, it doesn't work in
my case:

My setup is that username is unique, but not the emails (as opposed to
bakery code)

For me, it seems to be intuitive to use the validation of User model
in users/register, users/reset (where I'll get username and email) and
users/login (using User->validates()).

In users/reset and users/login, I haven't used User->save(), but User-
>validates() (In bakery code, they have duplicated the validation in
controller).

--
  <?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com    Blog: http://rajeshanbiah.blogspot.com/


--~--~---------~--~----~------------~-------~--~----~
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