1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){
$userChoix = $event->getData();
if(null === $userChoix ) { return; }
$question = $userChoix ->getQuestion();
$form = $event->getForm();
$form->add('choix', EntityType::class, array(
'class' => 'ITLessonsQuizBundle:Choix',
'multiple' => false,
'expanded' => true,
'choice_label' => 'reponse',
'choices' => $question->getChoices(),
'label' => $question->getQuestion()
));
});
} |
Partager