Add a hidden field containing the AdvancedEntry id to the form:

echo $form->input('BasicEntry.bacon');
echo $form->input('AdvancedEntry.id');
echo $form->input('AdvancedEntry.eggs');

(The `id` of the BasicEntry is transmitted to the edit action as the
1st parameter, so you don't need to do this for the primary model. It
doesn't hurt, though)

(id fields are hidden by default, so you don't need to specify it)

hth
grigri

On Oct 8, 9:45 am, Günther Theilen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> let's say there are two models:
>
> BasicEntry hasOne AdvancedEntry
> AdvancedEntry belongsTo BasicEntry
>
> In the advanced_entries table in the DB there is a field called
> "basic_entry_id"
>
> In views/basic_entries_edit.ctp there is something like this:
>
> $form->input('BasicEntry.foo');
> $form->input('AdvancedEntry.bar');
>
> In the basic_entries_controller/edit method I have:
>
> $this->BasicCity->save($this->data);
>
> which saves only the data for the BasicEntry.
> So I assumed I have to use saveAll() which doesn't work quite as I expected.
>
> If I don't set $this->data['AdvancedEntry']['id'] manually before
> saveAll I get an INSERT instead of an UPDATE.
> I set the value with something like this:
>
> $this->data['AdvancedEntry']['id'] =
>    $this->BasicEntry->AdvancedEntry->field('id', array(
>      'basic_entry_id' => $this->data['BasicEntry']['id']));
>
> Do I really have to do this manually or is there an automagic cake-like way?
>
> Regards
> Guenther
--~--~---------~--~----~------------~-------~--~----~
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