Bundle/BlogBundle/Controller/ArticleController.php
public function newAction(Blog $blog)
    {
        try {
            $article = new Article();
            $article->setBlog($blog);
            $form = $this->createForm(ArticleType::class, $article);

            return new JsonResponse([
                'html' => $this->container->get('templating')->render(
                    'VictoireBlogBundle:Article:new.html.twig',
                    [
                        'form'   => $form->createView(),
                        'blogId' => $blog->getId(),
                    ]
                ),
            ]);
        } catch (NoResultException $e) {
            return new JsonResponse([
                'success' => false,
                'message' => $e->getMessage(),
            ]);
        }
    }
public function newAction(Blog $blog)
    {
        try {
            $article = new Article();
            $article->setBlog($blog);
            $form = $this->createForm(ArticleType::class, $article);

            return new JsonResponse([
                'html' => $this->container->get('templating')->render(
                    'VictoireBlogBundle:Article:new.html.twig',
                    [
                        'form'   => $form->createView(),
                        'blogId' => $blog->getId(),
                    ]
                ),
            ]);
        } catch (NoResultException $e) {
            return new JsonResponse([
                'success' => false,
                'message' => $e->getMessage(),
            ]);
        }
    }
public function newAction ( Blog $ blog ) { try { $ article = new Article ( ) ; $ article -> setBlog ( $ blog ) ; $ form = $ this -> createForm ( ArticleType :: class , $ article ) ; return new JsonResponse ( [ 'html' => $ this -> container -> get ( 'templating' ) -> render ( 'VictoireBlogBundle:Article:new.html.twig' , [ 'form' => $ form -> createView ( ) , 'blogId' => $ blog -> getId ( ) , ] ) , ] ) ; } catch ( NoResultException $ e ) { return new JsonResponse ( [ 'success' => false , 'message' => $ e -> getMessage ( ) , ] ) ; } }
Display a form to create a new Blog Article.

@Route("/new/{id}", name="victoire_blog_article_new")
@Method("GET")

@return JsonResponse
Display a form to create a new Blog Article .