Bladeren bron

Merge pull request #2944 from webdevilopers/patch-3

Update action_list.rst
Thomas 10 jaren geleden
bovenliggende
commit
e913e7743e
1 gewijzigde bestanden met toevoegingen van 23 en 0 verwijderingen
  1. 23 0
      Resources/doc/reference/action_list.rst

+ 23 - 0
Resources/doc/reference/action_list.rst

@@ -428,6 +428,29 @@ If you have the **SonataDoctrineORMAdminBundle** installed you can use the ``doc
             return true;
         }
     }
+    
+You can also get the filter type which can be helpful to change the operator type of your condition(s):
+
+.. code-block:: php
+
+    use Sonata\CoreBundle\Form\Type\EqualType;
+
+    class UserAdmin extends SonataUserAdmin
+    {
+        public function getFullTextFilter($queryBuilder, $alias, $field, $value)
+        {
+            if (!$value['value']) {
+                return;
+            }
+            
+            $operator = $value['type'] == EqualType::TYPE_IS_EQUAL ? '=' : '!=';
+            
+            $queryBuilder->andWhere($alias.'.username ' . $operator . ' :username')
+                         ->setParameter('username', $value['value']);
+
+            return true;
+        }
+    }
 
 To do: