Add custom button in Component with form.

How can I add custom button on the left side of the "Save" button in Component with form?
7 Replies
Dan Harrin
Dan Harrin14mo ago
not sure what you mean by component but you can add an action to getFormActions()
StanProg
StanProg14mo ago
I used the following code, but nothing appears next to the "Save" button:
public function getFormActions(): array
{
return [Action::make('download')->label('Download')];
}
public function getFormActions(): array
{
return [Action::make('download')->label('Download')];
}
Also, I think that even if this worked, it would have generated an action at the top of the form, while I need it at the bottom, on the left side of the "Save" button. By "Component" I mean class MyClass extends Component implements HasForms
Dan Harrin
Dan Harrin14mo ago
oh so this isnt an admin panel page i didnt know how are you rendering the save button?
rabol
rabol13mo ago
Sorry for jumping in here - I have more or less the same question. I use the form builder in the front end like this:
<div class="container mx-auto">
<form wire:submit.prevent="save" >
{{ $this->form }}

<div class="w-full mt-4 grid grid-cols-2">
<div>
{{-- HERE I WOULD LIKE A CUSTOM ACTIOn BUTTON --}}
</div>
<div class="text-end">
<x-forms::button type="submit">
{{__('Save')}}
</x-forms::button>

</div>
</div>
</form>
</div>
<div class="container mx-auto">
<form wire:submit.prevent="save" >
{{ $this->form }}

<div class="w-full mt-4 grid grid-cols-2">
<div>
{{-- HERE I WOULD LIKE A CUSTOM ACTIOn BUTTON --}}
</div>
<div class="text-end">
<x-forms::button type="submit">
{{__('Save')}}
</x-forms::button>

</div>
</div>
</form>
</div>
Dan Harrin
Dan Harrin13mo ago
what do you want the button to do
rabol
rabol13mo ago
Call a action / method in my component maybe just a wire:click ? yes, sorry it's that simple - did not even think about that before now 🫣
FilamentDEV
FilamentDEV3mo ago
Any updates on this?