F
Filament9mo ago
Mexata

Opening a form modal from a widget

So im just gonna ask in here again, I have a widget on my dashboard:
<div class="col-md-6">
<p>Get started</p>
<x-filament::button
icon="heroicon-m-arrow-right"
icon-position="after"
href="{{ url(route(...)) }}"
tag="a"
>
Add to database.
</x-filament::button>
</div>
<div class="col-md-6">
<p>Get started</p>
<x-filament::button
icon="heroicon-m-arrow-right"
icon-position="after"
href="{{ url(route(...)) }}"
tag="a"
>
Add to database.
</x-filament::button>
</div>
and i have a form in a resource with a wizard:
public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([...])
public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([...])
now i want that button in the widget to open the form modal when it is pressed, but i have no clue how to do this can anyone help?
2 Replies
David Vincent
David Vincent9mo ago
you need to add a modal in your view : https://filamentphp.com/docs/3.x/support/blade-components/modal then you add the form into this modal content and your button should trigger $dispatch('open-modal', { id: 'edit-user' }) as mentioned in the doc
awcodes
awcodes9mo ago
Widgets are just livewire components, so you can just add an action to it that has the form. Then just echo the action in the widget’s view. https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component

Did you find this page helpful?