vendredi 10 avril 2015

Access (in Controller) an unmapped field nestled in a form collection

In a form I have nestled a delete checkbox in a collection of Answers. (each answer have a delete checkbox so that I can delete any answer easily)


But I do not succeed to access the delete value from the controller


Here the code: First I populated my form with the Answers



$Answers = $repository->liste_Answers_Child_Of_A_Question($question); // return a list of answers
$Answers = array('Answers' => $Answers);
$form = $this->createform(new AnswersType(),$Answers);


AnswersType (with a s)



$builder->add('Answers','collection', array('type'=> new AnswerType()));


AnswerType



$builder->add('Answer_text','text')
->add('delete','checkbox',array(
'mapped'=> false,))

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Site\BlogBundle\Entity\Answer'))
}


PS: I do not want to use the 'allow_delete' option combined with jquery.


Aucun commentaire:

Enregistrer un commentaire