Browse Source

Fix parent filter showing up when showing child list

Francisco Facioni 10 years ago
parent
commit
a4bc756229
3 changed files with 5 additions and 2 deletions
  1. 2 1
      Admin/Admin.php
  2. 1 1
      Filter/FilterInterface.php
  3. 2 0
      Resources/views/CRUD/base_list.html.twig

+ 2 - 1
Admin/Admin.php

@@ -887,7 +887,8 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         // ok, try to limit to add parent filter
         if ($this->isChild() && $this->getParentAssociationMapping() && !$mapper->has($this->getParentAssociationMapping())) {
             $mapper->add($this->getParentAssociationMapping(), null, array(
-                'field_type' => 'sonata_type_model_reference',
+                'label' => false,
+                'field_type' => 'sonata_type_model_hidden',
                 'field_options' => array(
                     'model_manager' => $this->getModelManager()
                 ),

+ 1 - 1
Filter/FilterInterface.php

@@ -54,7 +54,7 @@ interface FilterInterface
     /**
      * Returns the label name
      *
-     * @return string
+     * @return string|bool
      */
     public function getLabel();
 

+ 2 - 0
Resources/views/CRUD/base_list.html.twig

@@ -221,7 +221,9 @@ file that was distributed with this source code.
                                 <div class="filter_container">
                                     {% for filter in admin.datagrid.filters %}
                                         <div class="form-group" id="filter-{{ admin.uniqid }}-{{ filter.name }}" sonata-filter="{{ filter.options['show_filter'] ? 'true' : 'false' }}" style="display: {% if filter.isActive() and filter.options['show_filter'] %}block{% else %}none{% endif %}">
+                                            {% if filter.label is not sameas(false) %}
                                             <label for="{{ form.children[filter.formName].children['value'].vars.id }}" class="col-sm-3 control-label">{{ admin.trans(filter.label, {}, filter.translationDomain) }}</label>
+                                            {% endif %}
                                             {% set attr = form.children[filter.formName].children['type'].vars.attr|default({}) %}
                                             {#{% set attr = attr|merge({'class': (attr.class|default('') ~ ' sonata-filter-option')|trim}) %}#}