【发布时间】:2012-03-14 15:18:31
【问题描述】:
我正在尝试创建一个简单的表单来添加公司,但我在使用实体时遇到了麻烦。
我使用公司类型实体添加了一个选择字段:
->add('idtypesociete', 'entity', array('class' => 'PromocastUtilisateurBundle:PcastTypesociete', 'property' => 'nomtypesociete'))
但是当我提交表单时,我的 idtypesociete 字段包含一个“PcastTypesociete”对象,而不仅仅是所选选项的值。所以提交失败。
我在公司实体和 typeCompany 实体之间建立了多对一关系,如下所示:
/**
* @var integer $idtypesociete
*
* @ORM\Column(name="IDTYPESOCIETE", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Promocast\UtilisateurBundle\Entity\PcastTypesociete")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="PcastTypesociete_idtypesociete", referencedColumnName="idtypesociete")
* })
*/
private $idtypesociete;
您是否有解决方案来仅获取所选公司类型的 ID? (如果可能,无需发出简单的 sql 请求来列出我的公司类型)
非常感谢!
【问题讨论】: