php - Symfony2 Request-URI Too Long -


i have action, when send data, have

request-uri long. requested url's length exceeds capacity limit server

public function addaction(request $request) {     $productgallery = new productgallery();     $product = new product();     $productgallery->addproductgallerytoproduct($product);     $form = $this->createform(new productgallerytype(), $productgallery);     if($request->ismethod('post'))     {         $form->handlerequest($request);         if($form->isvalid())         {             $em = $this->getdoctrine()->getmanager();             $em->persist($productgallery);             $em->persist($product);             $em->flush();              return $this->redirecttoroute('addaction', array('form' => $form->createview()));         }     }     return array(       'form' => $form->createview()     ); } 

how can fixed it? wrong?

p.s form collection

public function buildform(formbuilderinterface $builder, array $options) {     $builder         ->add('productgallery_to_product', 'collection', array(             'type'           => new producttype(),             'allow_add'      => true,             'by_reference'   => false,             'allow_delete'   => true,             'prototype'      => true         ))     ; } 

new info

method 'post' in url

http://trololo.com/app_dev.php/add?form%5bvars%5d%5bid%5d=games_modelbundle_productgallery&form%5bvars%5d%5bname%5d=games_modelbundle_productgallery&form%5bvars%5d%5bfull_name%5d=games_modelbundle_productgallery&form%5bvars%5d%5bdisabled%5d=0&form%5bvars%5d%5bmultipart%5d=1&form%5bvars%5d%5bblock_prefixes%5d%5b0%5d=form&form%5bvars%5d%5bblock_prefixes%5d%5b1%5d=games_modelbundle_productgallery&form%5bvars%5d%5bblock_prefixes%5d%5b2%5d=_games_modelbundle_productgallery&form%5bvars%5d%5bunique_block_prefix%5d=_games_modelbundle_productgallery&form%5bvars%5d%5bcache_key%5d=_games_modelbundle_productgallery_games_modelbundle_productgallery&form%5bvars%5d%5bread_only%5d=0&form%5bvars%5d%5bvalid%5d=1&form%5bvars%5d%5brequired%5d=1&form%5bvars%5d%5bcompound%5d=1&form%5bvars%5d%5bmethod%5d=post&form%5bvars%5d%5baction%5d=&form%5bvars%5d%5bsubmitted%5d=1&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bid%5d=games_modelbundle_productgallery_productgallery_to_product&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bname%5d=productgallery_to_product&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bfull_name%5d=games_modelbundle_productgallery%5bproductgallery_to_product%5d&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bdisabled%5d=0&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bmultipart%5d=1&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bblock_prefixes%5d%5b0%5d=form&form%5bchildren%5d%5bproductgallery_to_product%5d%5bvars%5d%5bblock_prefixes%5d%5b1%5d=collection&form%5bchildren%5d%5bprodu.....

you're passing whole form view object in url:

$this->redirecttoroute('addaction', array('form' => $form->createview())); 

the second argument redirecttoroute() list of parameters send request.

this makes url long. exceeds web server limit, in turn refuses handle request.

your call should more this:

$this->redirecttoroute('addaction'); 

also, first argument redirecttoroute() method route name, not action method name. replace unless route name "addaction".

read more in controller chapter of documentation.


Comments