0

I have a form that contains forms. The form is link to the object "project" and it contains many forms linked to object "Assumptions". The relations between both is Project - Assumptions by 1..M

To create a project in my application I want to display the project formType but I don't want the AssumptionType form to be displayed yet.

What happens now is that when I done a form_end() in my twig, it renders a blank form of Assumption and so my project form is never valid (I assume it is linked to the fact it don't hide assumption forms)

So how can I make to not display those forms and make my project form valid?

Idos
  • 15,053
  • 14
  • 60
  • 75
  • 1
    http://stackoverflow.com/questions/10570002/how-to-make-form-rest-not-display-a-field-with-symfony2. And just as a side note, I find that is often easier to just define a new form type for this sort of stuff. I know it's tempting to try and reuse code but it often leads to confusion. – Cerad Jan 06 '16 at 13:45

1 Answers1

0

If you use a form containing others forms is because you needed in that way, if not, make a new one. If you insist in use that then you have to manage for make the second form hidden, using attr. Also remember that those forms are related to existing entities, so if the second form appears, surely means that the empty Project related to the form has at least one Assumptions. Clear the collection should work. I hope this help you.

abdiel
  • 2,078
  • 16
  • 24