If you set the value of id in your data array Cake assumes you are doing an 
update rather than an insert, so it might well be true that it validates. 
Sounds like you need to pull a set of ids from the database and remove them 
from the data array before attempting your save.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 21 Jun 2010, at 17:13, Josey wrote:

> Greetings,
> 
> I am attempting to validate data before a save in the controller
> 
> $this->data['Order']['orderid'] = 'ecommerceorderid#'
> 
> $this->Order->set($this->data);
> 
> $this->Order->validates();
> 
> ---------
> 
> I manually set $this->data['Order']['orderid'] to a value that is
> already present in the database and my model validation rules state
> that 'orderid' is set to 'isUnique'.
> 
> When I print $this->Order->validates();, however, the method returns a
> value of '1', which it should not due to the fact that the value is
> already in the database.
> 
> Am I missing something?
> 
> Basically my application pulls a list of orders from an exterior
> applications API based on a date range. Sometimes some of the items
> within that range may have been pulled at the end of a previous
> request so I want to exclude those from the save array BEFORE the save
> takes place so that all valid entries are logged and invalid ones are
> skipped altogether.
> 
> Thanks!
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to