Hi Tomasz,

Well, I guess you can leave doSave as is, and, instead, change the
nesting logic in the form, something like this:

$company = $this->getObject();
$address = $company->getAddress();
$newAddress = $address ? $address->duplicate() : new Address();
$company->addAddress($newAddress);
$this->embedForm('address', $newAddress);

If there's an existent address, then copy it, if not, create a new
one.

The duplicate method should return a copied Address object with the
relevant data, not a clone, a NEW object. This will ensure that a new
row will be inserted.

It's not too elegant, but does the work. Hope a better idea raises.

On 25 ene, 14:10, Tomasz <[email protected]> wrote:
> Hi.
> I have a module with nested form to referenced table in edit form.
> This situation:
>
> Company Table (id, ....)
> Company Address Table (id, company_id, ....)
>
> If I change Company info, it is updated. But when I change Company
> Address, I would like to save it as a new row. So that the old address
> is in table, but no longer used.
> To sum up how to change doSave in Company Address Module in order to
> save it each tima as a new row (but still constaint to Company
> object) ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" 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/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to