我有一个表单,我想在symfony2中的多个表中插入该表单中的数据。
我总共有5个表(实体),我试过这个,但它不起作用:
$company_var = new Company();
$adresses_var = new Adresses();
$contacts_var = new Contacts();
$licenses_var = new Licenses();
$owners_var = new Owners();
$form = $this->createForm(new NewformController(), $company_var);
$form = $this->createForm(new NewformController(), $adresses_var);
$form = $this->createForm(new NewformController(), $contacts_var);
$form = $this->createForm(new NewformController(), $licenses_var);
$form = $this->createForm(new NewformController(), $owners_var);
然后将它们保存到数据库中,如下所示:
$em->persist($company_var);
$em->persist($adresses_var);
$em->persist($contacts_var);
$em->persist($licenses_var);
$em->persist($owners_var);
$em->flush();
我听说过嵌入式表格,但我认为这对我不起作用。有什么想法吗?