coaster
coaster
FFilament
Created by coaster on 3/27/2025 in #❓┊help
Running action throws "using $this when not in object context"
I'm working in the table of a standard Filament resource. The documentation says I can do this: https://filamentphp.com/docs/3.x/tables/columns/getting-started#action-modals
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;

TextColumn::make('title')
->action(
Action::make('select')
->requiresConfirmation()
->action(function (Post $record): void {
$this->dispatch('select-post', post: $record->getKey());
}),
)
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;

TextColumn::make('title')
->action(
Action::make('select')
->requiresConfirmation()
->action(function (Post $record): void {
$this->dispatch('select-post', post: $record->getKey());
}),
)
So I did:
public static function table(Table $table): Table
{
return $table
->columns([
IconColumn::make('playerAssignments')
->icon('heroicon-o-pencil-square')
->action(
\Filament\Tables\Actions\Action::make('edit-player-assignments')
->action(function (Event $record): void {
$this->dispatch('open-player-assignments-modal', ['event' => $record]);
})
),
// ..
public static function table(Table $table): Table
{
return $table
->columns([
IconColumn::make('playerAssignments')
->icon('heroicon-o-pencil-square')
->action(
\Filament\Tables\Actions\Action::make('edit-player-assignments')
->action(function (Event $record): void {
$this->dispatch('open-player-assignments-modal', ['event' => $record]);
})
),
// ..
But when I click that icon, I get:
Using $this when not in object context

$this->dispatch('open-player-assignments-modal', ['event' => $record]);
Using $this when not in object context

$this->dispatch('open-player-assignments-modal', ['event' => $record]);
Seems odd they would put something in the docs that doesn't work, but maybe it's not intended for regular resource tables? I can't remove static from the table function here. I wouldn't even mind that the docs gave me erroneous code, if I could find a workaround, which I can't. What should I do?
4 replies
FFilament
Created by coaster on 1/30/2025 in #❓┊help
Add suffix to TextInputColumn?
No description
3 replies
FFilament
Created by coaster on 9/21/2024 in #❓┊help
Email attachments (FileUpload) not working
No description
2 replies