public function getFormAction($id)
    {
        /** @var Form $form */
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($id);

        if (!$form) {
            throw $this->createNotFoundException('The form could not be found');
        }

        /** @var Post $post */
        $post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
        $postForm = $this->createForm(PostType::class, $post, ['form_id' => $id]);

        $definition = $this->get('liform')->transform($postForm);

        /** @var CsrfTokenManagerInterface $csrf */
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->refreshToken($form->getName());

        // We're stuck with a legacy form structure here, which we'd like to hide on the API.
        $fields = $definition['properties']['valueset']['properties']['namedvalues']['properties'];
        $fields['_token'] = [
            'widget' => 'hidden',
            'value' => $token->getValue()
        ];

        return new JsonResponse($fields);
    }
public function getFormAction($id)
    {
        /** @var Form $form */
        $form = $this->get('opifer.form.form_manager')->getRepository()->find($id);

        if (!$form) {
            throw $this->createNotFoundException('The form could not be found');
        }

        /** @var Post $post */
        $post = $this->get('opifer.eav.eav_manager')->initializeEntity($form->getSchema());
        $postForm = $this->createForm(PostType::class, $post, ['form_id' => $id]);

        $definition = $this->get('liform')->transform($postForm);

        /** @var CsrfTokenManagerInterface $csrf */
        $csrf = $this->get('security.csrf.token_manager');
        $token = $csrf->refreshToken($form->getName());

        // We're stuck with a legacy form structure here, which we'd like to hide on the API.
        $fields = $definition['properties']['valueset']['properties']['namedvalues']['properties'];
        $fields['_token'] = [
            'widget' => 'hidden',
            'value' => $token->getValue()
        ];

        return new JsonResponse($fields);
    }
public function getFormAction ( $ id ) { /** @var Form $form */ $ form = $ this -> get ( 'opifer.form.form_manager' ) -> getRepository ( ) -> find ( $ id ) ; if ( ! $ form ) { throw $ this -> createNotFoundException ( 'The form could not be found' ) ; } /** @var Post $post */ $ post = $ this -> get ( 'opifer.eav.eav_manager' ) -> initializeEntity ( $ form -> getSchema ( ) ) ; $ postForm = $ this -> createForm ( PostType :: class , $ post , [ 'form_id' => $ id ] ) ; $ definition = $ this -> get ( 'liform' ) -> transform ( $ postForm ) ; /** @var CsrfTokenManagerInterface $csrf */ $ csrf = $ this -> get ( 'security.csrf.token_manager' ) ; $ token = $ csrf -> refreshToken ( $ form -> getName ( ) ) ; // We're stuck with a legacy form structure here, which we'd like to hide on the API. $ fields = $ definition [ 'properties' ] [ 'valueset' ] [ 'properties' ] [ 'namedvalues' ] [ 'properties' ] ; $ fields [ '_token' ] = [ 'widget' => 'hidden' , 'value' => $ token -> getValue ( ) ] ; return new JsonResponse ( $ fields ) ; }
Get a definition of the given form

@param $id

@return JsonResponse
Get a definition of the given form