getTableRecordKey(): Return value must be of type string, null
I suddenly get this error:
Filament\Resources\Pages\ListRecords::getTableRecordKey(): Return value must be of type string, null returned
In V2 I used to solve it by having this:
This doesn't seem to work anymore. this error came today after updating to the latest version.
the table query:
Solution:Jump to solution
well... the reason for the error was because of two entries in my DB that had no ID... my bad!
14 Replies
anyone have any solution? 🙂
Not sure why it complains about null return? Uniquid() shouldn’t be null right?
did you add in the ListPage file?
i saw that it said pages\ListRecords, so i moved the code into ListTimesheets.php, but then i get this error suddenly:
Do you have
'edit'
route in the getPages()
method?
If you are using a read-only table, you should remove the edit route/actionby commenting out it works. but I need to be able to edit
Curious to know how you will do this, considering you are using an auto UUID...
well, before today, when i updated to the latest release, i didn't have to overwrite the getTableRecordKey(). everything was working. and i just found that solution to overwrite the getTableRecordKey() function. haven't needed to do that before. (i tried to revert the update, but the error still excisists). i'll try to look for other changes and see if i find anything that has changed from working to not working verision of my app.
Not sure how it worked. How did it know which record to edit when there was no key? 🤔
I don't believe the issue is related to the Filament version, as the query you posted with an aggregation (sum) wouldn't work in even Filament v2. Unless you were employing a workaround similar to the one found here: https://v2.filamentphp.com/tricks/using-tables-with-aggregated-grouped-data
Filament
Using tables with aggregated / grouped data by Simon Bühler - Trick...
Filament is a collection of tools for rapidly building beautiful TALL stack apps, designed for humans.
i agree. and it isn't that query that causes it anyways. when i commenting out the widget, the error is still there. so it has to be somewhere else. I'm not doing anything with the query on the resource page.
So, why are you doing this?
->select(DB::raw('DATE(DATE_FORMAT(fra_dato, \'%Y-%m-01\')) AS month, SUM(totalt) AS Totalt'))...
?that's from the widget. i first thought it was the widget causing the problem. but when commenting out the widget, the error is still there.
Solution
well... the reason for the error was because of two entries in my DB that had no ID... my bad!