Reputation: 554
I'm working on a custom controller/function in symphony2/sonata admin panel. I want to render the file using:
return $this->render('SonataAdminBundle:CRUD:base_list.html.twig', array('entities' => $entities));
I get the error
Variable "form" does not exist in SonataAdminBundle:CRUD:base_list.html.twig
Hers the line in the twig:
<td class="filter-type">{{ form_widget(form.getChild(filter.formName).getChild('type')) }}</td>
Thanks.
Upvotes: 0
Views: 799
Reputation: 13167
I think you know that you need to pass the form to the view.
So I guess you haven't the form.
You need to work in the controller of the corresponding admin class (sonata) to render the Datagrid
form. Otherwise, you need to rewrite the whole logic.
That includes all the form building/processing using (or not) the DatagridMapper.
You should keep in mind that forms and lists represent the main components of sonata-admin (same for every admin panel), and although they are based on symfony forms, it represent a fully customised behavior.
So, for use sonata, you need to be in a sonata context. (In this case, of one of their CRUD actions)
Upvotes: 1
Reputation: 4129
You also have to pass the form view to render.
return $this->render('SonataAdminBundle:CRUD:base_list.html.twig', array('entities' => $entities, 'form' => $form->createView()));
Upvotes: 1