FilamentF
Filament3y ago
2 replies
현수

How do I add modal action to TableWidget like Resource?

I can open the modal window with the code below in the resource

class UserResource extends Resource
{
    public static function table(Table $table): Table
    {
        return $table
            // columns, filters...
            ->actions([
                Tables\Actions\Action::make('testAction')
                    ->form([
                        TextInput::make('testField')
                    ]),
            ]);
    }
}


But I can't open modals with the code below in the table widget

use Filament\Widgets\TableWidget as BaseWidget;
class MyTableWidget extends BaseWidget
{
    public function table(Table $table): Table
    {
        return $table
            ->query(MyModel::query())
            // columns...
            ->actions([
                Tables\Actions\Action::make('testAction')
                    ->form([
                        TextInput::make('testField')
                    ]),
            ]);
    }
}


I probably don't know much about the difference between Row action and basic action..........

Please let me know if there is a way to launch the modal window in TableWidget
Solution
This was the problem.

    public function getTableRecordKey(Model $record): string
    {
        // return uniqid();
        return $record->id;
    }
Was this page helpful?