BlogBundle/Controller/CategoryController.php
public function newAction(Request $request)
    {
        $category = new Category();
        $form = $this->createForm('BlogBundle\Form\CategoryType', $category);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($category);
            $em->flush();

            $this->get('session')->getFlashBag()->add('success', 'category.created');
            
            return $this->redirectToRoute('blog_category_index');
        }

        return array(
            'category' => $category,
            'form' => $form->createView(),
        );
    }
public function newAction(Request $request)
    {
        $category = new Category();
        $form = $this->createForm('BlogBundle\Form\CategoryType', $category);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($category);
            $em->flush();

            $this->get('session')->getFlashBag()->add('success', 'category.created');
            
            return $this->redirectToRoute('blog_category_index');
        }

        return array(
            'category' => $category,
            'form' => $form->createView(),
        );
    }
Creates a new Category entity.

@Route("/new")
@Method({"GET", "POST"})
@Template()