header action opens a create modal, followed by a confirmation modal

Is it possible to show another prompt saying Are you sure you want to add this category? after clicking Save?
No description
10 Replies
Nicole
NicoleOP3w ago
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->modalHeading('Author')
->modalSubmitActionLabel('Save')
->createAnother(false)
->label('Add Author'),
];
}
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->modalHeading('Author')
->modalSubmitActionLabel('Save')
->createAnother(false)
->label('Add Author'),
];
}
charlie
charlie3w ago
or use wire:confirm from native Livewire
Nicole
NicoleOP3w ago
I'll try it. So it is not possible like this?
CreateAction::make()
->modalHeading('Author')
->modalSubmitActionLabel('Save')
->createAnother(false)
->label('Add Author')
->before(function (CreateAction $action, $record) {
# I need another confirmation modal here with confirm and cancel button.
# Once confirmed, save the value
# Once cancelled, ignores it.
})
CreateAction::make()
->modalHeading('Author')
->modalSubmitActionLabel('Save')
->createAnother(false)
->label('Add Author')
->before(function (CreateAction $action, $record) {
# I need another confirmation modal here with confirm and cancel button.
# Once confirmed, save the value
# Once cancelled, ignores it.
})
charlie
charlie3w ago
I don't think so
Nicole
NicoleOP3w ago
Any idea how can I get the value of form field here?
Action::make('Add')
->form([
TextInput::make('name')
->required()
->maxLength(255),
])
->modalHeading('')
->modalSubmitActionLabel('Save')
->label('Add Author')
->action(function (array $arguments) {
dd($arguments);
$this->replaceMountedAction('save', $arguments);
})
Action::make('Add')
->form([
TextInput::make('name')
->required()
->maxLength(255),
])
->modalHeading('')
->modalSubmitActionLabel('Save')
->label('Add Author')
->action(function (array $arguments) {
dd($arguments);
$this->replaceMountedAction('save', $arguments);
})
charlie
charlie3w ago
use $data
Nicole
NicoleOP3w ago
I'll try, thanks cerr! Last Sir, seems I can't pass the data in saveAction()
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->modalHeading('Author')
->modalSubmitActionLabel('Save')
->createAnother(false)
->label('Add Author')
->action(function (array $data) {
$this->replaceMountedAction('save', $data);
})
];
}

public function saveAction(): Action
{
return Action::make('save')
->requiresConfirmation()
->modalHeading('Confirm Author?')
->modalSubmitActionLabel('Yes')
->modalCancelActionLabel('Cancel')
->action(function (array $data) {
dd($data);
PostAuthor::create($data);
});
}
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->modalHeading('Author')
->modalSubmitActionLabel('Save')
->createAnother(false)
->label('Add Author')
->action(function (array $data) {
$this->replaceMountedAction('save', $data);
})
];
}

public function saveAction(): Action
{
return Action::make('save')
->requiresConfirmation()
->modalHeading('Confirm Author?')
->modalSubmitActionLabel('Yes')
->modalCancelActionLabel('Cancel')
->action(function (array $data) {
dd($data);
PostAuthor::create($data);
});
}
toeknee
toeknee3w ago
GitHub
Chained actions · filamentphp filament · Discussion #11906
Package Table builder / Actions Package Version v3.2 How can we help you? Hello, I'm trying to figure out how can I achieve chained actions. By chained actions I mean that after edit action I w...
DEV Community
How to Trigger Another Action in FilamentPHP
If you have an Action in FilamentPHP and want to trigger another action sequentially within it, you...
Nicole
NicoleOP3w ago
Thank you @toeknee

Did you find this page helpful?