F
Filament6mo ago
Kitty

How do you add processing spinner to wizard button?

As an example, in a wizard the next button has a processing spinner but the submit does not, how do I add it to the submit?
Wizard::make($steps)
->submitAction(new HtmlString(Blade::render(
<<<'BLADE'
<x-filament::button
type="submit"
size="xl"
color="primary"
>

{{trans('Start Questionnaire')}}
</x-filament::button>
BLADE
)))
->nextAction(
fn (Action $action) => $action->color('primary'),
)
Wizard::make($steps)
->submitAction(new HtmlString(Blade::render(
<<<'BLADE'
<x-filament::button
type="submit"
size="xl"
color="primary"
>

{{trans('Start Questionnaire')}}
</x-filament::button>
BLADE
)))
->nextAction(
fn (Action $action) => $action->color('primary'),
)
Solution:
Maybe adding this wire:target="your_submit_method" to the button
Jump to solution
20 Replies
awcodes
awcodes6mo ago
It has one by default. Why are you overriding the view instead of modifying the existing submit action Iirc you should be able to
->submitAction(function(Action $action) {
return $action->size(‘xl’)->label(fn() => trans(‘label’));
})
->submitAction(function(Action $action) {
return $action->size(‘xl’)->label(fn() => trans(‘label’));
})
Something along those lines.
awcodes
awcodes6mo ago
Ah, ok. I would still expect it to have the spinner by default since the filament button view is tied to wire:loading.
Kitty
KittyOP6mo ago
I would expect it to, put it does not. When I view the code of the next button you can see the loader code. The submit button does not have it. This is the case for any <x-filament::button> on a custom page This is also the case when creating action in a resource
public function downloadResultAction(): Action
{
return Action::make('downloadResult')
->color('gray')
->label(trans('Download Summary'))
->url(fn (): string => route('download'));
}
public function downloadResultAction(): Action
{
return Action::make('downloadResult')
->color('gray')
->label(trans('Download Summary'))
->url(fn (): string => route('download'));
}
{{ $this->downloadResultAction }}
awcodes
awcodes6mo ago
Hmm, could be a bug, but looking at the button code it should be working unless there is an explicit alpineClickHandler assign on the action. Loading indicator is true by default. So as long as the action has a wire:click it should work. Maybe the livewire return is coming back quick enough to prevent it from showing but the dom diff is taking longer than expected. Hard to say.
Kitty
KittyOP6mo ago
In the wizard case it is copy paste from the documentation. The code is not there for the loader in the view.
No description
No description
Solution
LeandroFerreira
LeandroFerreira6mo ago
Maybe adding this wire:target="your_submit_method" to the button
Kitty
KittyOP6mo ago
That added the svg code but is not firing it. In the next button I can see it firing in the code regardless of the time it takes. My submit method is create(). Do I need to scope it to the resource? Or call it a different way? Sorry to reply to you
LeandroFerreira
LeandroFerreira6mo ago
Could you share the whole code?
Kitty
KittyOP6mo ago
Gist
Component
GitHub Gist: instantly share code, notes, and snippets.
Kitty
KittyOP6mo ago
Down on line 233 is the button
awcodes
awcodes6mo ago
Trying with just the name of the method. So ‘create’ instead of ‘create()’
Kitty
KittyOP6mo ago
Yes! That is working for the wizard.
LeandroFerreira
LeandroFerreira6mo ago
GitHub
How do you add processing spinner to wizard button? · filamentphp f...
Package Form builder Package Version v3.2 How can we help you? In a custom page. As an example, in a wizard the next button has a processing spinner but the submit does not, how do I add it to the ...
Kitty
KittyOP6mo ago
Yes
LeandroFerreira
LeandroFerreira6mo ago
Answered 😅
awcodes
awcodes6mo ago
Team work. 💪
Kitty
KittyOP6mo ago
Makes the dream work Is there anyway I can add a loader to Action Buttons? Like in this case:
public function downloadResultAction(): Action
{
return Action::make('downloadResult')
->color('info')
->label(trans('Download Summary'))
->url(fn (): string => route('download'));
}
public function downloadResultAction(): Action
{
return Action::make('downloadResult')
->color('info')
->label(trans('Download Summary'))
->url(fn (): string => route('download'));
}
LeandroFerreira
LeandroFerreira6mo ago
This is a link
Kitty
KittyOP6mo ago
I understand. The action buttons that are actions have the loader. Thanks so much for all your help
Want results from more Discord servers?
Add your server