scoumbourdis / grocery-crud

Grocery CRUD is a PHP Codeigniter Framework library that creates a full functional CRUD system without the requirement of extra customisation to the JavaScripts or the CSS to do it so.
http://www.grocerycrud.com
GNU General Public License v3.0
1.01k stars 471 forks source link

Undefined index: search_field #446

Open falkartis opened 6 years ago

falkartis commented 6 years ago

https://github.com/scoumbourdis/grocery-crud/blob/d2f71fba0e564bacec23990cd00497f1ed4d7741/application/libraries/Grocery_CRUD.php#L3235

I'm not sure about if this is the right solution but the idea is: Change search_field with search_text

scoumbourdis commented 6 years ago

Hello @falkartis can you please describe exactly what the problem is? When are you getting this error and with which theme?

falkartis commented 6 years ago

Yes, I see the description is quite short, I'm sorry for that.

The problem appears when in one page you use a filter on the search field (on the bottom) for a specific column and then you change to another page which doesn't have that column.

In my case php spits out two notices saying Undefined index: search_field.

The theme is flexigrid.

alzen8work commented 6 years ago

i believe this this bug: https://github.com/scoumbourdis/grocery-crud/commit/9d16ab5c98f765dca4a9127ce78d93d06e7f45ef

alzen8work commented 6 years ago

when empty($data['search_field']) $search_text = ''; //<----- suggest change to this? cos impossible to get $data['search_field'] when is empty ; - /

falkartis commented 6 years ago

I changed search_field to search_text and it made the job. I didn't read the whole file to understand what is going on behind the scenes, I just trusted my intuition. First $data['search_field'] must be Undefined because of the if statement. And second if the variable being assigned is $search_text it seems obvious to me that the key should also be search_text. I created this issue because I was not sure enough to create a pull request and all that stuff.