src/Controller/Framework/LsDefAssociationGroupingController.php
/**
     * Creates a new LsDefAssociationGrouping entity.
     *
     * @Route("/new", methods={"GET", "POST"}, name="lsdef_association_grouping_new")
     * @Template()
     * @Security("is_granted('create', 'lsdoc')")
     *
     * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
     */
Creates a new LsDefAssociationGrouping entity.


Creates a new LsDefAssociationGrouping entity .
public function newAction(Request $request)
    {
        $ajax = $request->isXmlHttpRequest();
        $associationGrouping = new LsDefAssociationGrouping();
        $form = $this->createForm(LsDefAssociationGroupingType::class, $associationGrouping);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            try {
                $command = new AddAssociationGroupCommand($associationGrouping);
                $this->sendCommand($command);
                if ($ajax) {
                    return new Response($associationGrouping->getId(), Response::HTTP_CREATED);
                }
                return $this->redirectToRoute('lsdef_association_grouping_show', array('id' => $associationGrouping->getId()));
            } catch (\Exception $e) {
                $form->addError(new FormError('Error adding new association group: '.$e->getMessage()));
            }
        }
        if ($ajax && $form->isSubmitted() && !$form->isValid()) {
            return $this->render('framework/ls_def_association_grouping/new.html.twig', ['form' => $form->createView()], new Response('', Response::HTTP_UNPROCESSABLE_ENTITY));
        }
        return [
            'lsDefAssociationGrouping' => $associationGrouping,
            'form' => $form->createView(),
        ];
    }
public function newAction ( Request $ request ) { $ ajax = $ request -> isXmlHttpRequest ( ) ; $ associationGrouping = new LsDefAssociationGrouping ( ) ; $ form = $ this -> createForm ( LsDefAssociationGroupingType :: class , $ associationGrouping ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { try { $ command = new AddAssociationGroupCommand ( $ associationGrouping ) ; $ this -> sendCommand ( $ command ) ; if ( $ ajax ) { return new Response ( $ associationGrouping -> getId ( ) , Response :: HTTP_CREATED ) ; } return $ this -> redirectToRoute ( 'lsdef_association_grouping_show' , array ( 'id' => $ associationGrouping -> getId ( ) ) ) ; } catch ( \ Exception $ e ) { $ form -> addError ( new FormError ( 'Error adding new association group: ' . $ e -> getMessage ( ) ) ) ; } } if ( $ ajax && $ form -> isSubmitted ( ) && ! $ form -> isValid ( ) ) { return $ this -> render ( 'framework/ls_def_association_grouping/new.html.twig' , [ 'form' => $ form -> createView ( ) ] , new Response ( '' , Response :: HTTP_UNPROCESSABLE_ENTITY ) ) ; } return [ 'lsDefAssociationGrouping' => $ associationGrouping , 'form' => $ form -> createView ( ) , ] ; }
Creates a new LsDefAssociationGrouping entity.
Creates a new LsDefAssociationGrouping entity .
// if ajax request, just return the created id