I'm trying to submit 2 symfony forms in one submit using ajax
var data = $('#facebookPostTargetForm').serialize();
data = data.concat("\r\n", $('#facebookPostForm').serialize());
$.ajax({
url: '{{ path('facebookpostwizard_new') }}',
type: "POST",
data: data,
dataType: 'html',
success: function(data){
//console.log(data);
alert('OK');
}
});
almost everything is working properly except the case that in my controller when I use $form->handleRequest($request)
i get some trouble getting the last field of first form(mostly _token so $form->isValid()
always return false) and first field of second one!!!! I don't put a snippet of my controller here because if I only submit one form everything works perfect, it seems to be related to the data.concat() but I've tried a lot of things and it doesn't work. Thanks in advance!