dyam
Close modal from List HeaderActions
I'm having problems with closeing a modal inside a list header actions:
The ID is random and unique. So on opening the id changes. Dispatch close is not working.
How to close the modal after the action?
class ListHabits extends ListRecords
{
protected static string $resource = HabitResource::class;
protected function getHeaderActions(): array
{
return [
Action::make('createOrDuplicateHabit')
->label(('Habits'))
->form([
Forms\Components\Tabs::make('habits_tabs')
->tabs([
Forms\Components\Tabs\Tab::make(('Add'))
->schema([]),
Forms\Components\Tabs\Tab::make(('Load from library'))
->schema([
Forms\Components\Grid::make(3)
->schema(),
])
]),
])
->action(function (array $data): void {
if (isset($data['title']) && isset($data['unit'])) {
$habit = new Habit();
//
$habit->save();
Notification::make()
->success()
->title(('Added'))
->body(__('Added'))
->send();
// Close the modal
// ID of the modal is unkown
}
})
];
4 replies