qilir
qilir
FFilament
Created by qilir on 3/25/2024 in #❓┊help
Open a Modal from inside of an Action
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('generateToken')
->label('Generate Token')
->button()
->hidden(fn(string $operation) => $operation === "create")
->requiresConfirmation(fn(Client $client) => $client->tokens()->exists())
->modalHeading('Generate new Token')
->modalDescription('Are you sure you want to generate a new Token? Existing ones will be deleted.')
->action(function (Client $client) {
$tokenName = $client->client_name;
$client->tokens()->delete();
$token = $client->createToken($tokenName, ['server:update'])->plainTextToken;

//show a modal that displays the plainTextToken
dump($token);

}),
]),
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('generateToken')
->label('Generate Token')
->button()
->hidden(fn(string $operation) => $operation === "create")
->requiresConfirmation(fn(Client $client) => $client->tokens()->exists())
->modalHeading('Generate new Token')
->modalDescription('Are you sure you want to generate a new Token? Existing ones will be deleted.')
->action(function (Client $client) {
$tokenName = $client->client_name;
$client->tokens()->delete();
$token = $client->createToken($tokenName, ['server:update'])->plainTextToken;

//show a modal that displays the plainTextToken
dump($token);

}),
]),
Hi, im currently building a small internal tool and thought it would be the perfect opportunity to give Filament a try, since I thought I didn't need any custom components :D Its my first time using either Filament or Livewire, so it might just be that this is a really stupid question. So I added an Action to my Edit-Form that generates a Sanctum API-Token, for us to be able to use the token, I want to display the plainTextToken once after generation, preferrably in a modal. Is there any way to open a modal that just shows the token from inside this action?
6 replies