浏览代码

fix nested admin filtering

Thomas Rabaix 14 年之前
父节点
当前提交
a9e220f312
共有 4 个文件被更改,包括 6 次插入9 次删除
  1. 1 1
      Admin/Admin.php
  2. 4 4
      Filter/Filter.php
  3. 0 1
      Filter/ORM/Filter.php
  4. 1 3
      Filter/ORM/IntegerFilter.php

+ 1 - 1
Admin/Admin.php

@@ -1193,7 +1193,7 @@ abstract class Admin implements AdminInterface
             if (!is_numeric($id)) {
                 $this->subject = false;
             } else {
-                $this->subject = $this->getModelManager()->find(
+                $this->subject = $this->getModelManager()->findOne(
                     $this->getClass(),
                     $id
                 );

+ 4 - 4
Filter/Filter.php

@@ -29,9 +29,9 @@ abstract class Filter implements FilterInterface
 
     public function __construct(FieldDescriptionInterface $fieldDescription)
     {
-        $this->name         = $fieldDescription->getName();
-        $this->fieldDescription  = $fieldDescription;
-        $this->options      = array_replace(
+        $this->name               = $fieldDescription->getName();
+        $this->fieldDescription   = $fieldDescription;
+        $this->options            = array_replace(
             $this->getDefaultOptions(),
             $this->fieldDescription->getOption('filter_options', array())
         );
@@ -66,7 +66,7 @@ abstract class Filter implements FilterInterface
 
     public function getOption($name, $default = null)
     {
-        if (array_keys($this->options, $name)) {
+        if (array_key_exists($name, $this->options)) {
             return $this->options[$name];
         }
 

+ 0 - 1
Filter/ORM/Filter.php

@@ -17,7 +17,6 @@ use Symfony\Component\Form\FormBuilder;
 
 abstract class Filter extends BaseFilter
 {
-
     public function apply($queryBuilder, $value)
     {
         $this->value = $value;

+ 1 - 3
Filter/ORM/IntegerFilter.php

@@ -22,8 +22,6 @@ class IntegerFilter extends Filter
             return;
         }
 
-        $value      = sprintf($this->getOption('format'), $value);
-
         // c.name > '1' => c.name OPERATOR :FIELDNAME
         $queryBuilder->andWhere(sprintf('%s.%s %s :%s',
             $alias,
@@ -32,7 +30,7 @@ class IntegerFilter extends Filter
             $this->getName()
         ));
 
-        $queryBuilder->setParameter($this->getName(), (int)$value);
+        $queryBuilder->setParameter($this->getName(), (int)sprintf($this->getOption('format'), $value));
     }
 
     public function getDefaultOptions()