[Bug] Undefined array key "attribute" while filtering
See original GitHub issueBug report
What I did
This was working in Laravel 7 and backpack 4 after the upgrade this error apear when using basic filters As i debugged i see that “attribute” isnt present in applySearchLogicForColumn function line 85
The field in my controller is defined as following
$this->crud->addField([
'label' => 'Series', // Label for HTML form field
'type' => 'select', // HTML element which displaying transactions
'name' => 'serie_id', // Table column which is FK for Customer table
'entity' => 'serie', // Function (method) in Customer model which return transactions
'attribute' => 'id', // Column which user see in select box
'model' => 'Serie' // Model which contain FK
]);
Is it a bug in the latest version of Backpack?
Yes
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version
the output is:
Issue Analytics
- State:
- Created a year ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Undefined variable", "Notice: Undefined index", "Warning ...
This notice/warning appears when you (or PHP) try to access an undefined index of an array. The notices above appear often when working...
Read more >Undefined array key "field_geofield_proximity_op" when using ...
Problem/Motivation When using the proxmitiy filter on a non node entity, I'm seeing the following PHP error. Warning: Undefined array key ...
Read more >Undefined array key - community, help and support
I'm working on upgrading a site from J3 to J4 and using the GiMeSpace Bootstrapped Menu module. Everything appeared to be working fine...
Read more >Filtering undefined elements from an array in TypeScript
So the type of the product variable is Product | undefined . When we use an if statement (or equivalent) to check its...
Read more >“Undefined array key” when using relevanssi_orderby filter w ...
“Undefined array key” when using relevanssi_orderby filter w post order plugin ... If I remove the filter the warnings go away, and if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@GoatFreezy I’m not using any filters (I didn’t purchase a PRO version yet). Anyways, I found a solution. Rename your columns and remove the ‘
_id
’ part. In my case I changedCRUD::column('company_id')
toCRUD::column('company')
After that change everything works fine.
@Nemachtilli @rommeA
Thanks for getting back here. I think I may have some idea where the error happens now I will have a look at it right way.
company
andcompany_id
in your cases should return exactly the same attributes from the relationship guessing process but somehow for you guys is not working properly.I will investigate and get back to you guys. Also what you can do is defining
'attribute' => 'some_attribute_from_model_you_want_to_show_user'
Cheers