i don't know how to handle the request in my controller in symfony in the php code. So im creating a new model in my collection with collection.create() method but I don't know how to handle it in symfony php code. Can anyone help me?
Collection.create() code:
save: function()
{
this.collection.create({
title: $("#title").val()
});
console.log(this.collection);
}
PHP code:
/**
* @Route("/document")
*/
public function createAction(Request $request)
{
$content = $request->getContent();
$document = new Document();
$em = $this->getDoctrine()->getManager();
$em->persist($document);
$em->flush();
return new JsonResponse($document);
}
Request method: POST, status: OK