I want to use the same formType several times in the same page, so in my Controller i have something like:
$form = $this->createForm(new updateSortieForm(), $sortie);
return $this->render('vue.html.twig,array('form'=>$form));
in my vue, i have loop which is supposed to render this form following a simple condition!
{% if sortie.dateretoueffective == null %}{
{{ form(form,{'action':path('update_sortie',{'idSortie':sortie.idSortie}) })}}}
{% endif %}
the problem is that i need to instantiate this form multiple times, i've already tried this method: it doesn't work, or maybe i'm doing something wrong, as i'm new to Symfony!
my form class is pretty simple:
class updateSortieForm extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options){
$builder->add('dateRetouEffective','date',array('label'=>false))
->add('MAJ','submit');
}
public function getName()
{
return 'alfarabiBundle_AlfarabiAppBundle_updateSortie'; }
}
constructormethod that take the form name as parameter to differentiate the two formsnamein yourupdateSortieFormclass then$form1 = new updateSortieForm();$form1->setName('form1');for your instantiation$this->createForm($form1, $sortie);and do the same thing to form2