angularjs - symfony2 form how to accept json payload from angular resource -
i'm trying combine symfony form angularjs
... service posts data form, should save entity database. unfortunately, ngresource
sends data json payload, symfony forms can't process it... tried many things on angular side, changing headers:
headers : {'content-type': 'application/x-www-form-urlencoded'}
i couldn't find more on angular side, thought find solution on symfony side. idea how work? angular-solutions welcome of course.
i found solution, after reading deeper in documentation. symfony\component\form\form::bind
doesn't require request, works array too. here's solution (the sloppy way, need checking of header, etc. production use..)
public function setfooaction(request $request){ $form = $this->createform();//get form class, etc... $json_data = json_decode($request->getcontent(),true);//get response data array $form->bind($json_data); //bind data form if ($form->isvalid()) { ... } }
Comments
Post a Comment