custom modal content

I make a filament page and implement HasTable, i want to make action view with modal and use custom modal content, but the modal not show up and no error,
public function table(Table $table): Table
{
return $table
->actions([
ActionsAction::make('view')
->modalContent(view('filament.pages.actions.detail-profit-and-loss'))
])
}
public function table(Table $table): Table
{
return $table
->actions([
ActionsAction::make('view')
->modalContent(view('filament.pages.actions.detail-profit-and-loss'))
])
}
but if use
protected function getHeaderActions(): array
{
return [
Action::make('view')
->modalContent(
fn(): View => view('filament.pages.actions.detail-profit-and-loss', [
'record' => '',
])
)
];
}
protected function getHeaderActions(): array
{
return [
Action::make('view')
->modalContent(
fn(): View => view('filament.pages.actions.detail-profit-and-loss', [
'record' => '',
])
)
];
}
its work, but that not what i want, i want to add action on the table
16 Replies
toeknee
toeknee5mo ago
Action needs an action.. so ->action(fn($record) => '') otheriwse actions are not rendered.
agampradhana
agampradhanaOP5mo ago
the action button is rendered, but the modal not show up when clicked
toeknee
toeknee5mo ago
Exactly because you haven't defined an action.
public function table(Table $table): Table
{
return $table
->actions([
ActionsAction::make('view')
->modalContent(view('filament.pages.actions.detail-profit-and-loss'))
->action(fn() => '')
])
}
public function table(Table $table): Table
{
return $table
->actions([
ActionsAction::make('view')
->modalContent(view('filament.pages.actions.detail-profit-and-loss'))
->action(fn() => '')
])
}
Might work... But tbh? I would say you will need a form? I.e.
return $table
->actions([
ActionsAction::make('view')
->form([
ViewField('filament.pages.actions.detail-profit-and-loss')
])
->action(fn() => '')
])
return $table
->actions([
ActionsAction::make('view')
->form([
ViewField('filament.pages.actions.detail-profit-and-loss')
])
->action(fn() => '')
])
Table actions are designed to be an actionable button which runs an action simply.
agampradhana
agampradhanaOP5mo ago
but why when i use same action on Resource table its work
toeknee
toeknee5mo ago
Because you used it in a header opposed to a table. Tables render lots of rows and for performance action is assumed.
agampradhana
agampradhanaOP5mo ago
no, i use it on the table also, not the header
toeknee
toeknee5mo ago
Where?
agampradhana
agampradhanaOP5mo ago
No description
toeknee
toeknee5mo ago
But you stated above that doesn't work?
agampradhana
agampradhanaOP5mo ago
No description
agampradhana
agampradhanaOP5mo ago
this is on a Resource
toeknee
toeknee5mo ago
Ok so then you need to add the modal call in the custom view
<x-filament-actions::modals />
<x-filament-actions::modals />
to the footer of the page? Could possible solve it.
agampradhana
agampradhanaOP5mo ago
No description
agampradhana
agampradhanaOP5mo ago
not work also
agampradhana
agampradhanaOP5mo ago
No description
agampradhana
agampradhanaOP5mo ago
its not work also

Did you find this page helpful?