If it's showing the correct values when viewing but not when saving,
then the form might be submitting to /employees/edit and not to /
employees/edit/:id as you're presuming.

1. Does it work if you remove the line ($this->Employee->id = $id)?
2. Replace pr() with debug(). What is the output in each case?
3. How is your Employee model set up?

On Aug 12, 8:03 am, tron <[email protected]> wrote:
> I have a problem with one specific controller trying to INSERT instead
> of UPDATE and I am getting duplicate entry errors. the "$this->data"
> variable contains the correct primary key of table I'm trying to
> update, but still tries to INSERT instead. Most notable text message
> is this in the debug dump: SELECT COUNT(*) AS `count` FROM `employees`
> AS `Employee` WHERE `Employee`.`id` IS NULL. Apparently its not
> getting the id at all?
>
> Code:
>
>         function        edit( $id = null )
>         {
>         pr( $id );
>         pr( $this->data );
>         $this->Employee->id = $id;
>
>         if( !empty( $this->data ) )
>         {
>             if( $this->Employee->save( $this->data ) )
>             {
>             }
>
>         } else {
>             $this->data = $this->Employee->read( null, $id );
>         }
>         }
>
> Both the pr functions display the correct data that suggests it should
> be doing an UPDATE instead of INSERT.
--~--~---------~--~----~------------~-------~--~----~
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