Closed kunjalpopat closed 11 years ago
Could you provide the content of BloggerBlogBundle:Default:gcrud.html.twig ?
below are my BloggerBlogBundle:Default:gcrud.html.twig content {{ crud(crud) }}
Mmmhh... that's strange...
the "crud()" function calls the method "renderCrud()" in file CrudExtension.php, which calls "render()" in the same file with only 2 arguments. So the $params argument must be an empty array and you should not have trouble with the array_merge.
have you the last version of the bundle ? It "{{ crud(crud) }}" the complete content of the template ? Could you provide the controller ?
Thanks iamluc
Bundle version : yes, i have download on 14-June Content : {{ crud(crud) }} Controller :
$em = $this->getDoctrine()->getEntityManager(); $entities = $em->getRepository('BloggerBlogBundle:Blog')->findAll(); return $this->render('BloggerBlogBundle:Default:gcrud.html.twig', array('crud' => $this->get('gloomy.crud')->factory('BloggerBlogBundle:Blog'), 'entities' => $entities ));
Hello iamluc
I have send you bundle version, content & controller code in lasts questions, that are actually emergency for me
Thanks Kunjal
Hi,
In file /MY_PROJECT/src/Gloomy/PagerBundle/Twig/CrudExtension.php, could you try to replace this code in function render($crud, $block, $params = array())
if ($template->hasBlock($block)) {
return $template->renderBlock($block, array_merge($params, array('crud' => $crud)));
}
by
if ($template->hasBlock($block)) {
if (!is_array($params)) {
if (is_object($params)) {
throw new \Exception('Params should be an array, but is object '.get_class($params));
}
else {
throw new \Exception('Params should be an array, but is '.gettype($params).' containing '.$params);
}
}
return $template->renderBlock($block, array_merge($params, array('crud' => $crud)));
}
and tell me which exception is raised ?
Given me following error when i have replace code..
An exception has been thrown during the rendering of a template ("Params should be an array, but is NULL containing ") in BloggerBlogBundle:Default:gcrud.html.twig at line 1.
Ok, i have an idea. Have you create a Form Type for your entity : "Form/BlogType.php" ?
no
You must do it. you can use this command : php app/console generate:doctrine:form BloggerBlogBundle:Blog
i have use this command but given me same error
An exception has been thrown during the rendering of a template ("Params should be an array, but is NULL containing ") in BloggerBlogBundle:Default:crud.html.twig at line 1.
The file "Form/BlogType.php" has been generated ?
yes, Form/BlogType.php has been generated.
New idea !
You don't use the CRUD object correctly. According to the README, it's
return $this->get('gloomy.crud')->factory('MyBundle:MyEntity')->handle();
You must call the handle() method, and it will return an array to give to your template. If you want to pass other arguments, you must add them in the same array
Thanks iamluc i have try your new idea replace below code and its working when i click on Add button.. return $this->render('BloggerBlogBundle:Default:crud.html.twig', $this->get('gloomy.crud')->factory('BloggerBlogBundle:Blog')->handle());
but when save data given me below error.........
Catchable Fatal Error: Argument 2 passed to Symfony\Bundle\FrameworkBundle\Controller\Controller::render() must be an array, object given, called in /MY_PROJECT/src/Blogger/BlogBundle/Controller/DefaultController.php on line 78 and defined in /MY_PROJECT/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php line 97
after i have try this ways return $this->render('BloggerBlogBundle:Default:crud.html.twig', array('crud' => $this->get('gloomy.crud')->factory('BloggerBlogBundle:Blog')->handle()));
but not working.
Hi,
The handle() method returns an array or a Response object. If you use the Template() annotation, you can just do
return $this->get('gloomy.crud')->factory('BloggerBlogBundle:Blog')->handle();
But if you don't use annotation, you can do:
$crud = $this->get('gloomy.crud')->factory('BloggerBlogBundle:Blog')->handle();
if (!is_array($crud)) {
return $crud;
}
return $this->render('BloggerBlogBundle:Default:crud.html.twig', $crud);
Hi iamluc
i have used your code & now its working.
Thankyou.
I have download Gloomy Pager Bundle package and it worked well with Gloomy Pager, Datagrid, CRUD functionality, but when i will try to use Gloomy CRUD functionality in another bundle when i will try to add new record on it. giving following error creating new record using Gloomy CRUD.
An exception has been thrown during the rendering of a template ("Warning: array_merge(): Argument #1 is not an array in /MY_PROJECT/src/Gloomy/PagerBundle/Twig/CrudExtension.php line 79") in BloggerBlogBundle:Default:gcrud.html.twig at line 1.
Thanks Kunjal