src/AppBundle/Controller/BarcoController.php
/**
     * Creates a new barco entity.
     *
     * @Route("/{cliente}/nuevo", name="barco_new")
     * @Method({"GET", "POST"})
     */
Creates a new barco entity.
Creates a new barco entity .
public function newAction(Request $request,Cliente $cliente)
    {
        $barco = new Barco();
        $motor = new Motor();
        $barco->addMotore($motor);
        $barco->setEstatus(true);
        $form = $this->createForm('AppBundle\Form\BarcoType', $barco);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $barco->setCliente($cliente);
            $fechaHoraActual = new \DateTime('now');
            $barco->setFecharegistro($fechaHoraActual);
            $em->persist($barco);
            $em->flush();
            return $this->redirectToRoute('cliente_show', array('id' => $barco->getCliente()->getId()));
        }
        return $this->render('barco/new.html.twig', array(
            'barco' => $barco,
            'cliente' => $cliente,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request , Cliente $ cliente ) { $ barco = new Barco ( ) ; $ motor = new Motor ( ) ; $ barco -> addMotore ( $ motor ) ; $ barco -> setEstatus ( true ) ; $ form = $ this -> createForm ( 'AppBundle\Form\BarcoType' , $ barco ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ barco -> setCliente ( $ cliente ) ; $ fechaHoraActual = new \ DateTime ( 'now' ) ; $ barco -> setFecharegistro ( $ fechaHoraActual ) ; $ em -> persist ( $ barco ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'cliente_show' , array ( 'id' => $ barco -> getCliente ( ) -> getId ( ) ) ) ; } return $ this -> render ( 'barco/new.html.twig' , array ( 'barco' => $ barco , 'cliente' => $ cliente , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new barco entity.
Creates a new barco entity .