我正在尝试使用表单的监听器(尝试使用pre_set_data和pre_bind),但是我收到此错误
缺少必需的选项“class”。
public function bindData(DataEvent $event) {
$data = $event->getData();
$form = $event->getForm();
if (null === $data) {
return;
}
$form->add($this->factory->createNamed('citta','entity', array(
'label' => 'form.citta',
'empty_value' => 'form.scelta',
'required' => true,
'translation_domain' => 'FOSUserBundle',
'class' => 'MyBundle:GeoNames',
'property' => 'geonameid',
'query_builder' => function(\MyBundle\GeoBundle\Entity\GeoNamesRepository $er) {
//return $er->getCountry();
},
)));
//}
}
同样如果它被放入静脉形式中看到了正确的
我也尝试
$form->add($this->factory->createNamed('citta','entity',null, array(
但我有
Expected argument of type "Doctrine\ORM\QueryBuilder", "NULL" given
我正在关注食谱
答案 0 :(得分:0)
应该是:
$form->add($this->factory->createNamed('citta','entity', null, array(
请参阅第45行的代码:/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php