1
我的實體做一個列表字段編輯時,這個領域是採用奏鳴曲項目的Symfony
/**
* @ORM\ManyToOne(targetEntity="Estat", inversedBy="temes")
*/
private $estat;
public function setEstat(\Ncd\ForumBundle\Entity\Estat $estat = null)
{
$this->estat = $estat;
return $this;
}
我管理一個many_to_one型
protected function configureListFields(ListMapper $listMapper)
{
//$estats=$this->getEstatsPossibles()->toArray();
$estats=array();
foreach($this->getEstatsPossibles() as $estat)
{
$estats[$estat->getId()]=$estat->getNom();
}
$listMapper
->add('estat', 'choice',['editable' => true,'choices'=> $estats])
我想打在ESTAT場編輯列表網格。這樣做,我得到了它的可編輯性,一個組合框出現,但是當我選擇一個選項時,我得到一個異常,因爲我的實體的setEstat函數不會收回Estat實體,而是一個字符串(數組的鍵)。
試圖
->add('estat', 'many_to_one',['editable' => true,'choices'=> $estats])
只顯示一個鏈接到實體沒有任何可能改變。
可能嗎?