Filtering stops working after adding Laminas Where clause

Hi, Johnny!

I will take your “example/customers” view and “Example.php” controller (customers table) as example :slight_smile: and add the following lines:

use Laminas\Db\Sql\Where;

    public function customers()
        $where = new Where();
        $where->notLike('country', '%USA%');
        $output = $crud->render();

        return $this->_example_output($output);

The code/addition is functioning correctly as expected. However, a problem has arisen, as the quick search filters, as well as the Filter button, are currently non-functional and do not produce any effect.

Could you please take a look at this issue?

Bernhard Enders

:worried: You are right! I can also reproduce the issue! I will have it a look and let you know.

Hello @bgeneto,

I’ve fixed the issue for the next version but since the next version will be delayed (e.g. it will probably be released mid August) I am sending you the change that you will need to do:

diff --git a/src/GroceryCrud/Core/Model.php b/src/GroceryCrud/Core/Model.php
index 56926cb..7741251 100755
--- a/src/GroceryCrud/Core/Model.php
+++ b/src/GroceryCrud/Core/Model.php
         if ($this->_where !== null) {
-            $select->where($this->_where);
+            $select->where([$this->_where]);
         return $select;

If you are using composer then go to: vendor/grocery-crud/enterprise/src/GroceryCrud/Core/Model.php and change this line at line 1058. And also for your zip file, unzip the composer package change the code to src/GroceryCrud/Core/Model.php and then zip it again with the filename:

Sorry for the extra steps. If you can wait till mid August for the next release even better :slight_smile:


1 Like

Hello @bgeneto,

I am glad to inform you that this is now fixed for the latest version (3.0.10) which you can download from here: User's Page Login

Keep in mind that now Grocery CRUD supports multiple where statements that they are adding up. For example:

$crud->where(['customer_name' => 'John']);
$crud->where(['country' => 'Greece']);

will result to:

'customer_name' => 'John',
'country' => 'Greece'

Let me know if that worked for you and thank you for your detailed feedback :grinning:


Whoa, that’s amazing! Thank you! I will test this version ASAP and report back if I found any issues.

1 Like