I thought as much...

If you add the id field:
echo $this->Form->input('id');

...Cake will automatically i) hide it and ii) populate it with the id value of 
the record. Make sure the id value is part of the data you are sending to the 
form (die(debug($this->data)) will confirm that).

Then when you submit the form, Cake will detect the id value and do an update. 
If it is empty, it will do an insert.

The validation will fire in the same way on both. The id value *has* to be 
unique, so the validation is doing its job.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 13 May 2011, at 13:23, heohni wrote:

> Oha!
> 
> My fault!!
> echo $form->hidden('agent_id'); <== WRONG
> echo $form->hidden('id', array('value' => $this->data['Agent']
> ['id'])); <== RIGHT!!
> 
> But I can't use isUnique, because this rule also proofs on UPDATES but
> I need it only on ADD - what can I finally do?
> 
> On 13 Mai, 14:14, heohni <[email protected]> wrote:
>> Even when I deactivate the isUnique validation rule, open my edit
>> form, and empty one of the required fields and submit, I get the
>> expected error message.
>> BUT when I add a new value into this field and I submit I get a new
>> dataset saved in my DB.
>> 
>> I really don't understand this....
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to