question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Undefined array key "attribute" while filtering

See original GitHub issue

Bug 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

image 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: image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
rommeAcommented, Apr 7, 2022

@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 changed CRUD::column('company_id') to CRUD::column('company')

After that change everything works fine.

1reaction
pxpmcommented, Jul 4, 2022

@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 and company_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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found