Using symfony 2.6 and twig : I have answers provided by a lot of users in my database. I want to create a form linsing all of them for a given user, to allow him to edit them.
I get these responses with the following code :
Controller :
$responses = $this->getDoctrine()->getRepository('AppBundle:Response')
->findBy(
array('user' => $usr,
'response' => 1,
'response' => 2
),
array('id' => 'ASC')
);
$form = $this->createForm(new ActionType, $responses)->createView();
ActionType :
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('check', 'entity', array(
'required' => false,
'class' => 'AppBundle:Response',
'property' => 'id',
'property_path' => '[id]',
'multiple' => true,
'expanded' => true,
))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => null,
'csrf_protection' => false
));
}
This answer does exactly what I want, but I can't get it working. The form generated is way too huge : it takes the whole Response table... Do you have any clue why ?