1
我要收回語美洲實體InscritSeminaireType:Symfony2的 - 實體表單類型query_builder
class InscritSeminType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
//->add('dateInscrit')
->add('seminaire','entity', array(
'class' => 'EspritSeminaireBundle:Seminaire',
'query_builder' => function($repository)use ($id) {
return $repository->getSeminaireLibre('id')
->setParameter('id', $id)
;
},
'required' => false,
))
//->add('etudiant')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$resolver->setDefaults(array(
'data_class' => 'Esprit\SeminaireBundle\Entity\InscritSemin',
));
}
public function getName() {
return 'esprit_seminairebundle_inscritsemintype';
}
}
但它返回一個錯誤:
Notice: Undefined variable: id in C:\wamp\www\PFE\EOL\src\Esprit\SeminaireBundle\Form\InscritSeminType.php line 22
所以可能有人告訴我,我怎麼能解決這個問題?
哪一行是「第22行」? – luiges90
實際上,在查詢構建器的回調之前,Id沒有定義。 – gremo