User table list omits the status column
I created a resource for managing the users table and one of the columns on the table is called 'status'. For some bizarre reason this column does not get listed in the table. If however I change the column name in the database to something other than 'status' then it will be displayed/listed normally....
Table code as generated by filament when the resource was created is:-
Tables\Columns\TextColumn::make('status')
->searchable(),
Any ideas?Solution:Jump to solution
Done some more testing with this. It doesn't have to be the 'status' column. It seems that if any column is made toggleable and gets hidden using the selector then even if the toggleable() attribute is removed from the table's schema definition then it stays hidden and cannot be displayed until toggleable is restored and the column is reset to visible. Once that is done then the toggleable() can be removed...
Where is the toggleable status remembered? Local storage?...
32 Replies
Can you share the full table definition?
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('firstname')
->searchable(),
Tables\Columns\TextColumn::make('lastname')
->searchable(),
Tables\Columns\TextColumn::make('email')
->searchable(),
Tables\Columns\TextColumn::make('mobile')
->searchable(),
Tables\Columns\TextColumn::make('email_verified_at')
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('avatar_url')
->searchable(),
Tables\Columns\TextColumn::make('status')
->searchable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
]);
}
Weird one. What does a
toArray()
on your model return?Here's an example from the db
[
"id" => 3,
"firstname" => "Client",
"lastname" => "User",
"email" => "[email protected]",
"mobile" => "099933011",
"email_verified_at" => null,
"avatar_url" => null,
"status" => "Active",
"created_at" => "2023-08-18T20:04:05.000000Z",
"updated_at" => "2023-08-18T20:04:05.000000Z",
"full_name" => "Client User",
"breezy_sessions" => [],
]
If it helps here are the attributes for the same user from dumping a get() of the getEloquentquery() in the resource:-
#attributes: array:12 [▼
"id" => 3
"firstname" => "Client"
"lastname" => "User"
"email" => "[email protected]"
"mobile" => "099933011"
"email_verified_at" => null
"password" => "$2y$10$eJmL/1wpyrMgB4wX19tLxeuBsdxsAAKF1wle09cqjHrw6I4LTqrPy"
"remember_token" => null
"avatar_url" => null
"status" => "Active"
"created_at" => "2023-08-18 20:04:05"
"updated_at" => "2023-08-18 20:04:05"
]
Can you dump a
->toArray()
Here you go
2 => array:12 [▼
"id" => 3
"firstname" => "Client"
"lastname" => "User"
"email" => "[email protected]"
"mobile" => "099933011"
"email_verified_at" => null
"avatar_url" => null
"status" => "Active"
"created_at" => "2023-08-18T20:04:05.000000Z"
"updated_at" => "2023-08-18T20:04:05.000000Z"
"full_name" => "Client User"
"breezy_sessions" => []
]
Hm weird. Looks fine to me. Was the column
toggleable()
before?
Does this show up?
1.
2.
Do you have a status relationship on the records model?
Yeah, maybe share your model code
Exception Method Filament\Tables\Columns\TextColumn::getRecordUsing does not exist
Sorry.
getStateUsing
'status_test' is listed 'status' is still missing
What about this:
Was the column toggleable() before?
Can you try adding toggleable
lol
That's what I was thinking Dennis 😄
No - the resource is as generated by filament
Can you try in an incognito browser window?
I added
->toggleable()
no change status is missing from list stillCan you see the status as toggleable in the toggleable list now?
Okay - that works ...
Sounds like something stored in browser cache then
Okay - thanks for your help (@toeknee too!) .. will clear cache/cookies and start over
Correction - it only seems to work with toggleable() added - I removed it from incognoto session and it isn't listed again...
Yeah a toggleable filter for status was stored
Do:
->toggleable(isToggledHiddenByDefault: false)
It is still not listed but appears in the toggleable field list then appears when selected
I think the default is alredy set by now.
Twas for his inprivate sessions 😉
Can you provie a github repo to replicate it
so if toggleable has been added then it is rememered and applied even if the toggleable attribute is removed?
Yes possibly since the togglebale is session based
Yeah, that sounds like an issue. Can you please open one on GH with a reproduction repo?
Shouldn't be applied though, if you remove it
True
Solution
Done some more testing with this. It doesn't have to be the 'status' column. It seems that if any column is made toggleable and gets hidden using the selector then even if the toggleable() attribute is removed from the table's schema definition then it stays hidden and cannot be displayed until toggleable is restored and the column is reset to visible. Once that is done then the toggleable() can be removed...
Where is the toggleable status remembered? Local storage?
IT is in session storage and that would be expected tbh because it's not something you do often.
okay understood