Tables Action does nothing

I am trying to open a modal / execute an action from a table. Unfortunately, absolutely nothing happens. It rotates briefly in the frontend, but the code in the action is not executed either.
13 Replies
Dennis Koch
Dennis Koch7mo ago
The ViewAction works? You don't have another test action on that page, right?
Iven S. | LvckyWorldᶜʳᵉʷ
yes, i don't have a other test action and view action doesnt work too like you can see in the attached video but on other sites/relations the viewaction works like it should
Dennis Koch
Dennis Koch7mo ago
Right, sorry. Hm. Is this a default view page or a custom page?
Iven S. | LvckyWorldᶜʳᵉʷ
Okay, I have a PlanResource it's a default Resource (class PlanResource extends Resource) there i have a relation:
#[\Override]
public static function getRelations(): array
{
return [
'planComponents' => PlanComponentsRelationManager::class,
];
}
#[\Override]
public static function getRelations(): array
{
return [
'planComponents' => PlanComponentsRelationManager::class,
];
}
This relation was resolved by:
class PlanComponentsRelationManager extends RelationManager
class PlanComponentsRelationManager extends RelationManager
and in PlanComponentsRelationManager there is the table with a action. And that action is not doing anything:
class PlanComponentsRelationManager extends RelationManager
{
protected static string $relationship = 'planComponents';

protected static ?string $title = "Komponenten";

#[\Override]
public function form(Form $form): Form
{
return $form
->schema([
ViewField::make("_notice")
->visibleOn('create')
->columnSpan(2)
->label('Hinweis'),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
// columns
])->actions([
Tables\Actions\ViewAction::make(),
Action::make('test')
->requiresConfirmation()
->modalHeading('Test')
// ->modalSubmitAction(false)
->modalCancelAction(fn(StaticAction $action) => $action->label(__('filament-actions::view.single.modal.actions.close.label')))
->form([
TagsInput::make('test')
->label('Interval')
])
->action(function() {
Notification::make('message')
->title('Test')
->body('This is test')
->success()
->send();
}),
])
}
}
class PlanComponentsRelationManager extends RelationManager
{
protected static string $relationship = 'planComponents';

protected static ?string $title = "Komponenten";

#[\Override]
public function form(Form $form): Form
{
return $form
->schema([
ViewField::make("_notice")
->visibleOn('create')
->columnSpan(2)
->label('Hinweis'),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
// columns
])->actions([
Tables\Actions\ViewAction::make(),
Action::make('test')
->requiresConfirmation()
->modalHeading('Test')
// ->modalSubmitAction(false)
->modalCancelAction(fn(StaticAction $action) => $action->label(__('filament-actions::view.single.modal.actions.close.label')))
->form([
TagsInput::make('test')
->label('Interval')
])
->action(function() {
Notification::make('message')
->title('Test')
->body('This is test')
->success()
->send();
}),
])
}
}
Edsardio
Edsardio7mo ago
@Iven S. | LvckyWorldᶜʳᵉʷ did you find a solution for this? Stumbling upon the same. When clicking the row it seems to fire a close-modal event instead of an open-modal event but have no clue what causes it
Iven S. | LvckyWorldᶜʳᵉʷ
No, no solution That's the exact same problem
Edsardio
Edsardio7mo ago
Do you by any chance use UUID as the primary key instead of an ID?
Iven S. | LvckyWorldᶜʳᵉʷ
Yes i am using UUID In the sushi model/model define The key as 'string'
Edsardio
Edsardio7mo ago
Could you check if your model has the "HasUuids" trait? That was the fix for us
Iven S. | LvckyWorldᶜʳᵉʷ
protected $primaryKey = 'id'; protected $keyType = 'string'; My model only has the Sushi trait
Edsardio
Edsardio7mo ago
This trait was what I had forgotten to add to the model, once added the modals started working again. Might work for you as well, Illuminate\Database\Eloquent\Concerns\HasUuids
No description
Iven S. | LvckyWorldᶜʳᵉʷ
And this has fixed the problem with 'close-modal' for you?
Edsardio
Edsardio7mo ago
Yeah It is a requirement when using uuids instead of integers, but I just forgot
Want results from more Discord servers?
Add your server