I need to send a data from a Symfony form with an Ajax call with an extra Data containing options for the controller.
I'm working on a custom framework including the Symfony form component.
So I try in my JS to send values like this :
$.ajax
(
{
type: "POST",
url: '/myUrl',
data:
{
'formData' : $(this).serialize(),
'extraData' : {'test1' : 'test1', 'test2' : 'test2'}
},
success: function(result)
{
// do something
}
}
);
How can I get my form data in my controller to let the component correctly understand it ? This code won't work :
$formData = $this->getRequest()->request('formData');
$form->bind($formData);
Thank you. I hope my question is clear enough
Edit: I finally integrated the data into hidden fields in my form. The form doesn't declare any data_class, as the ORM we use is a really custom one. Thanks for the answers
$form->bind($_POST['formData']);?