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 schem开发者_JAVA技巧a :
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);
You need to use embedRelation. You can find more information and examples here: http://prendreuncafe.com/blog/post/2009/11/29/Embedding-Relations-in-Forms-with-Symfony-1.3-and-Doctrine
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论