public function createAction(Request $request, $categoryId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Category $category */
        $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);

        if (!$category) {
            throw $this->createNotFoundException('Unable to find Category entity.');
        }

        $entity  = new Category();
        $form = $this->createForm(new SubcategoryType(), $entity);
        $entity->setParentCategory($category);

        $form->bind($request);

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

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

            return $this->redirect($this->generateUrl('ecommerce_category_show', array('id' => $entity->getId())));
        }

        return array(
            'entity' => $entity,
            'category' => $category,
            'form'   => $form->createView(),
        );
    }