Skip to content

Commit

Permalink
datagrid category value must be object, it was being set to integer
Browse files Browse the repository at this point in the history
  • Loading branch information
codebach committed May 9, 2016
1 parent b676113 commit da3c13f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions Controller/MediaAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,18 @@ public function listAction(Request $request = null)
$category = $this->container->get('sonata.classification.manager.category')->getRootCategory($context);

if (!$filters) {
$datagrid->setValue('category', null, $category->getId());
$datagrid->setValue('category', null, $category);
}

if ($request->get('category')) {
$contextInCategory = $this->container->get('sonata.classification.manager.category')->findBy(array(
$contextInCategory = $this->container->get('sonata.classification.manager.category')->findOneBy(array(
'id' => (int) $request->get('category'),
'context' => $context,
));

if (!empty($contextInCategory)) {
$datagrid->setValue('category', null, $request->get('category'));
$datagrid->setValue('category', null, $contextInCategory);
} else {
$datagrid->setValue('category', null, $category->getId());
$datagrid->setValue('category', null, $category);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Resources/views/MediaAdmin/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ file that was distributed with this source code.
<ul{% if root %} class="sonata-tree sonata-tree--small js-treeview sonata-tree--toggleable"{% endif %}>
{% for element in collection %}
<li>
<div class="sonata-tree__item{% if element.id == current_category %} is-active{% endif %}"{% if depth < 2 %} data-treeview-toggled{% endif %}>
<div class="sonata-tree__item{% if element.id == current_category.id %} is-active{% endif %}"{% if depth < 2 %} data-treeview-toggled{% endif %}>
{% if element.parent or root %}<i class="fa fa-caret-right" data-treeview-toggler></i>{% endif %}
<a class="sonata-tree__item__edit" href="{{ url(app.request.attributes.get('_route'), app.request.query.all|merge({category: element.id})) }}">{{ element.name }}</a>
</div>
Expand Down

0 comments on commit da3c13f

Please sign in to comment.