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 Harrin2y ago
not sure what you mean by component but you can add an action to getFormActions()
StanProg
StanProgOP2y 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 Harrin2y ago
oh so this isnt an admin panel page i didnt know how are you rendering the save button?
rabol
rabol2y 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 Harrin2y ago
what do you want the button to do
rabol
rabol2y 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 🫣
gemini.dev
gemini.dev8mo ago
Any updates on this?
Want results from more Discord servers?
Add your server