Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ********************* MON CONTROLEUR*****************************
- public function ajouterCategorieAction( Request $request )
- {
- $nombreProduit = 4 ;
- $categorie = new Categorie();
- $form = $this->createForm(new CategorieType(), $categorie ) ;
- $produit = new Produit();
- $form2 = $this->createForm(new ProduitType(), $produit);
- /*
- $test = $this->container->get('chauss_land_stock.Chauss_land_form_produit') ;
- $form = $this->createForm( $test->buildForm() , $produit);
- $test = $this->container->get('chauss_land_stock.chauss_land_form_produit');
- $produit = new Produit;
- // On crée le FormBuilder grâce à la méthode du contrôleur
- $form = $this->createForm( $this->container->get('chauss_land_stock.Chauss_land_form_produit') , $produit);
- $form = $this->container->get('chauss_land_stock.form_produit');
- $produit = new Produit;
- // On crée le FormBuilder grâce à la méthode du contrôleur
- $form = $this->createForm(new ProduitType, $produit);
- */
- // On récupère la requête
- //$request = $this->getRequest() ;
- //echo 'bonjour : '.$request->getMethod();
- // On vérifie qu'elle est de type POST
- if ($request->isMethod('POST'))
- {
- echo 'post' ;
- if ($form->isValid())
- {
- // On redirige vers la page de visualisation de l'article nouvellement créé
- return $this->redirect( path('Chauss_land_administration_homepage') ) ;
- }
- else if ($form2->isValid())
- {
- // On redirige vers la page de visualisation de l'article nouvellement créé
- return $this->redirect( path('Chauss_land_administration_homepage') ) ;
- }
- }
- else if ($request->isMethod('GET'))
- {
- echo 'get' ;
- }
- else
- {
- //echo 'other' ;
- }
- // On passe la méthode createView() du formulaire à la vue afin qu'elle puisse afficher le formulaire toute seule
- return $this->render('ChaussLandStockBundle:StockController:addCategorie.html.twig', array( 'form' => $form->createView(), 'form2' => $form2->createView(), 'nombreProduit' => $nombreProduit ) ) ;
- }
- }
- ********************* MON FORM *****************************
- <div class="well">
- Nombre de categorie : {{ nombreProduit }}
- <form action="{{ path('Chauss_land_administration_addCategorie') }}" method="post" {{ form_enctype(form2) }}> {{ form_widget(form2) }} <input name="formCat1" type="submit" /> </form>
- <form action="{{ path('Chauss_land_administration_addCategorie') }}" method="post" {{ form_enctype(form) }}> {{ form_widget(form) }} <input name="formCat" type="submit" /> </form>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement