F
Filament12mo ago
jals65

Errors in table builder with a livewire component.

Hi, I am experiencing several problems with the Table Builder on a custom page. I have a custom page in which I have added a livewire component that I have made following the documentation you have to build a table. One of the problems is that when I select a row to be able to execute the bulk action, all the rows are selected, and when I try to deselect one, they are all deselected. It is impossible to select 1 single row. Another problem I'm experiencing is that simple actions that have ->form() and ->requiresConfirmation() don't open modal.
13 Replies
Patrick Boivin
Patrick Boivin12mo ago
Can you share some code?
toeknee
toeknee12mo ago
And also check your browser console for notices/errors
jals65
jals6512mo ago
No errors on the browser console
cheesegrits
cheesegrits12mo ago
Try commenting out that getTableRecordKey method.
jals65
jals6512mo ago
When I comment it, it trows an error
jals65
jals6512mo ago
This is the response of the request of the action with modal.
jals65
jals6512mo ago
Other problem that I'm getting is when I search in the serchable column, it duplicates some records on the table
cheesegrits
cheesegrits12mo ago
Something weird is going on, because you should not have to implement getTableRecordKey(), the default implementation should handle it. But the reason all your records are being selected is that you are giving them all the same key value. That function should return something like $record->id, ie. the primary key value, not a static string. You do have a PK set on that model / table, right?
jals65
jals6512mo ago
The PK of that model is the path, but I don't want to show the path in the table, I just want to show the name and the number of screenshots it has.
public function getTableRecordKey(Model $record): string
{
return $record->getAttribute(VisualTestingBaselineInterface::NAME);
}
public function getTableRecordKey(Model $record): string
{
return $record->getAttribute(VisualTestingBaselineInterface::NAME);
}
with this, it works and the problem of the searchable colum is solved It only remains to solve the problem with the simple actions modal
toeknee
toeknee12mo ago
You get the erro getTableRecordKey because your relationship has returned null or you have an incorrect relationship, i.e. hasMany oppsed to belongsToMany
cheesegrits
cheesegrits12mo ago
Don't think he's using any relationships. It's just a simple table with two fields. And he shouldn't have to implement that function. I think it may be something to do with the select on the getTableQuery, which is probably forcing the query to only return those two fields, and not the PK. @jals65 - even if you aren't displaying the PK, it still needs to be selected, so Filament has the id. Also, can't you just cast that JSON field in the model, rather than doing a JSON select by hand?
jals65
jals6512mo ago
I just did tests and that is why, if I return the path in the query, it does allow me to comment on the getTableRecordKey function Since I wasn't returning it, it couldn't find it About the problem with the simple actions modal, do you know anything?