views:

118

answers:

0

Hello,

I have two classes with a relation one-to-many. And I want to make a nested form to enter an object and some of others which are linked to it.

But when I save the form, the key wich references my main class isn't update with the key of main class. However the other keys are created.

My schema :

Enfant:
  connection: doctrine
  tableName: enfant
  columns:
    id:
      type: integer(2)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
    nudparent:
      type: string(20)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
  relations:
    Locataire:
      local: nudparent
      foreign: nud
      type: one
Locataire:
  connection: doctrine
  tableName: locataire
  columns:
    nud:
      type: string(20)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    nbenfants:
      type: integer(1)
      fixed: false
      unsigned: true
      primary: false
      notnull: false
      autoincrement: false
  relations:
    Bail:
      local: nud
      foreign: locataire
      type: many
    Enfant:
      local: nud
      foreign: nudparent
      type: many
    Refus:
      local: nud
      foreign: nud
      type: many

And making form :

$subForm = new sfForm();
for ($i = 0; $i < 2; $i++)
{
    $enfant = new Enfant();
    $enfant->Locataire = $this->getObject();

    $form = new EnfantForm($enfant);

    $subForm->embedForm($i, $form);
 }
 $this->embedForm('new', $subForm);