【发布时间】:2012-07-05 17:05:55
【问题描述】:
我目前正在使用使用 Symfony 2.1.0-DEV 和 Doctrine 2.2.x 的 Sonata Admin Bundle,但我遇到了 Many-To 问题- 许多实体关联:
class MyProduct extends Product {
/**
* @ORM\ManyToMany(targetEntity="Price")
*/
private $prices;
public function __construct() {
$this->prices = new \Doctrine\Common\Collections\ArrayCollection()
}
public function getPrices() {
return $this->prices;
}
public function setPrices($prices) {
$this->prices = $prices;
}
}
// Admin Class
class GenericAdmin extends Admin {
...
public function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('General')
->add('prices', 'sonata_type_model')
->end()
;
}
}
...
}
现在,如果尝试从 Sonata 的 CRUD create/edit 表单面板向多对多关联添加价格,则更新不起作用。
关于这个问题的任何提示?谢谢!
【问题讨论】:
标签: php doctrine-orm symfony-sonata symfony-2.1