F
Filament13mo ago
Laurens

Keep create action modal open on success with feedback

Is it somehow possible to keep the modal of a create action open after the record has been created? I'd like to show the feedback with some data which shouldn't be available to the user when they close the modal after creating a record. Thanks in advance!
14 Replies
toeknee
toeknee13mo ago
Not out of the box, you could alter the create action to a normal action, with a wizard, which is submit, then feedback?
Laurens
LaurensOP13mo ago
Should the final step then show feedback? As chaining ->using(function (array $data) after the final step also just closes the wizard 🤔
toeknee
toeknee13mo ago
So you would need to use ->AfterStepUpdated() and on the 2nd to final step of the wizard and the save it, and just have a close / dismiss or the final submit is to action the feedback 😉
Laurens
LaurensOP13mo ago
AfterStepUpdated doesn't seem to exist here. I've found afterValidation but it doesn't seem to get called. What could be happening here?
Actions\Action::make('create')
->steps([
Step::make('Name')
->description('Give the category a unique name')
->schema([
TextInput::make('name')->required(),
])
->columns()
->afterValidation(function ($data) {
dd($data);
}),
])
Actions\Action::make('create')
->steps([
Step::make('Name')
->description('Give the category a unique name')
->schema([
TextInput::make('name')->required(),
])
->columns()
->afterValidation(function ($data) {
dd($data);
}),
])
there isn't a difference due to this being inside the Manage page of a "simple" resource right?
Quin.
Quin.13mo ago
There are no errors also?
Laurens
LaurensOP13mo ago
with the code above the Action::make() just closes without an exception This is on Filament v3.0.96 & Laravel v10.32.1
toeknee
toeknee13mo ago
Because you have not defined an action.
Actions\Action::make('create')
->steps([
Step::make('Name')
->description('Give the category a unique name')
->schema([
TextInput::make('name')->required(),
])
->columns()
->afterValidation(function ($data) {
dd($data);
}),
])
->action(fn($data) => dd($data))
Actions\Action::make('create')
->steps([
Step::make('Name')
->description('Give the category a unique name')
->schema([
TextInput::make('name')->required(),
])
->columns()
->afterValidation(function ($data) {
dd($data);
}),
])
->action(fn($data) => dd($data))
Laurens
LaurensOP13mo ago
The data being dumped there for me is from the action though, afterValidation still doesn't run if I change the dd in action to 'action', its the string and not the array of data 🙂 Same result in a default resource, so it's not because of the simple resource at least 🤔
toeknee
toeknee13mo ago
Actions\Action::make('create')
->steps([
Step::make('Name')
->description('Give the category a unique name')
->schema([
TextInput::make('name')->required(),
])
->afterValidation(function (Closure $get, $set) {
dd($get('name'));
}),
])
->action(fn($data) => dd($data))
Actions\Action::make('create')
->steps([
Step::make('Name')
->description('Give the category a unique name')
->schema([
TextInput::make('name')->required(),
])
->afterValidation(function (Closure $get, $set) {
dd($get('name'));
}),
])
->action(fn($data) => dd($data))
Laurens
LaurensOP13mo ago
Did it work for you locally? Because here I'm always only getting the dump from the action, never from after validation 🤔 Mine sits in getHeaderActions of a Manage page inside a Simple resource
toeknee
toeknee13mo ago
It does on V2.... but on a column action
Laurens
LaurensOP13mo ago
Seems to be no longer working on V3 then 😦 We also had quite a few translation issues which worked on V2 but all broke in V3. Will probably have to figure out custom components then like plugins I guess
toeknee
toeknee13mo ago
The code is there for it to run, so I'd say to try and look into it more Can you check what filament version you are on? php artisan about
Laurens
LaurensOP13mo ago
This is on Filament v3.0.96 & Laravel v10.32.1 🙂
Want results from more Discord servers?
Add your server