Cake's "isUnique" method handles create & update situations well (so
you do not need "on" => "create" at all). Are you sure that you make
update? It is the common error - do not provide ID to model when want
update and it makes create instead. And do not "respect" the key "on"
of course because it makes create actually.

On Sep 10, 12:50 am, brian <[email protected]> wrote:
> On Wed, Sep 9, 2009 at 1:42 PM, brian <[email protected]> wrote:
> > I have the following validatio rules:
>
> > 'email' => array(
> >        'valid' => array(
> >                'rule' => 'email',
> >                'required' => true,
> >                'allowEmpty' => false,
> >                'message' => 'You must provide an email address.'
> >        ),
> >        'duplicate' => array(
> >                'rule' => 'isUnique',
> >                'on' => 'create',
> >                'message' => 'This email address is already registered with 
> > us.
> > Because members use this as their login, the address must be unique.'
> >        )
> > )
>
> > When editing a profile, I keep getting the 'duplicate' error msg. Am I
> > using the 'on' param correctly? Is there something else necessary?
> > Looking around online, there are scads of user-provided methods--some
> > I've used myself--but my interpretation of isUnique was that it's
> > enitrely built-in to Cake.
>
> I mean to add that Cake's query is:
>
> SELECT COUNT(*) AS `count` FROM `users` AS `Student` WHERE
> `Student`.`email` = '[email protected]'
>
> I'd have though it would include "AND Student.id != ..." That would
> seem more efficient than checking for the id in the result. But I
> can't even locate where the code that handles this is. I've looked
> through Validation class but I'm not seeing it.
>
> In any case, it shouldn't even be firing on an edit!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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