Noob, a question related to FOSRestBundle, JMSSerializerBundle and templates.
I am trying to replace some existing code that is currently outputting json via twig to use FOSRestBundle. This was successful when the content passed from the controller was initially in arrays, but now I'm trying to pass the form to a FOSRestBundle, as a result, my values ββare never returned.
The code below replicates the script
public function getAction($id) { ... $form = $this->createFormBuilder(array('myValue' => 'SOMEVALUE')) ->add('myValue', 'hidden') ->getForm(); $view = FOSView::create($form); $view->setFormat('json'); return $this->get('fos_rest.view_handler')->handle($view); }
returns
{"children":{"_token":[],"myValue":[]}}
what I expected to see here was something like:
{"children":{"_token": "mylongtoken","myValue": "SOMEVALUE"}}
I based my code on examples in LiipHelloBundle, if I am not mistaken, does this correspond to the examples they provide? Any ideas I'm wrong about?
php symfony fosuserbundle
Madmanmonty
source share