我有两个具有一对多关系的类。我想制作一个嵌套表单来输入一个对象以及与之链接的其他一些对象。
但是当我保存表单时,引用我的主类的键不会用主类的键更新。但是,会创建其他密钥。
我的架构:
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
并制作表格:
$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);