Hi

I'd the same problem in my first Update view. It "forgets" the ID so when
Save() checks if it must be Inserted or Updated; it Inserts it.

Sometimes it happened when I was trying to edit something and the
information was not validated; so the same display is shown; but with Id
forgotten.

I've solved it echoing an Input Type=Hidden in the view as follows:

echo $form->input('Admin.id', array('type' => 'hidden'));


Admin.Id is now always present in the page.

You may solve it using

    echo $form->input('Info.id', array('type' => 'hidden'));
    echo $form->input('Profile.id', array('type' => 'hidden'));

May be only one of them, may be both.


Sure this is not the Cake-Style; but I share what I've done with you and
then wait for the real solution.


Greets

On Thu, Apr 24, 2008 at 10:57 PM, Chez17 <[EMAIL PROTECTED]> wrote:

>
> I am creating a basic facebook type site for my first cake project,
> just to learn it. I am having issues getting the save funciton to work
> with my model relationships. Its very simple right now, the modle
> Profile hasOne Info. The Info model belongsTo Profile and stores all
> the contact information. I just have a model, no controller for Info
> because all it needs to do is store data. In my Profile controller I
> can't it to save the Info model correctly. It keeps creating new
> database records and not updaitng the old one. Here is my code:
>
> function account()
> {
>    $temp = $this->Profile->findbyUserId($this->Session-
> >read('user_id'));
>    $this->set('info',$this->Profile->Info-
> >findbyProfileId($temp['Profile']['id']));
>
>    if (!empty($this->data))
>    {
>        if($this->Profile->Info->save($this->data))
>        {
>            $this->Profile->Info->saveField('profile_id',
> $temp['Profile']['id']);
>            $this->set("success", "true");
>        }
>    }
> }
>
> Also, its not saving my foreign keys so I have to manually save
> profile_id after, I'm completely new so I don't know if I'm missing
> out on anything. Should I have to do that every time? Any help is
> appreciated. I am using the latest stable version of 1.1.
>
> Thanks,
> Dave
>
> >
>


-- 
Nicolás Andrade
www.nicoandra.com.ar
www.treintaguita.com.ar

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