1

I have a serious problem about symfony2 forms, the issue that I created a very long form,so I build it with parts(fields),so In the same form sometime I sumbit this part(fields) and I hide another using display:none and javascript code:

$('#{{form.price.vars.id}}').live('change', function(){
if ( $(this).is(':checked') ) {
 $('#action_{{form.price.vars.id}}').show();
} else {
 $('#action_{{form.price.vars.id}}').hide();
}
});

....

    <ul id="action_{{form.price.vars.id}}" style="display:none">
<li>{{ form_row(form.price_value)  }}</li>
<li>{{ form_row(form.price_subscription)  }}{{form_row(form.price_subscription_unit)}}</li>
<li>{{ form_row(form.price_activation)  }}{{form_row(form.price_activation_unit)}}</li>
</ul>
...

So when I hide this fields and I click submit the form still give me that this hidden fields are empty and I must enter a value,that is means the part is hide in the client side(html code) but in backend side he still not hide?

after submitting and when I show hidden fields to see what happend I have a notification "please enter a value in emply field"?

1 Answer 1

1

You need to use validation groups for this.

Nothing better than a Richard Miller post: Symfony2: Using Validation Groups. Take a particular look at Multiple Forms with one Entity.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.