F
Filamentβ€’4mo ago
Twixzor

Modal resource editing

Is there a possibility to call a Filament modal from Alpinejs, where i can edit or create a resource?
10 Replies
LeandroFerreira
LeandroFerreiraβ€’4mo ago
from your List page? pleas provide more info..
Twixzor
TwixzorOPβ€’4mo ago
I have a blade component from which I want to open a modal either for editing or creating depending on the condition and I want to fill out the same form as if I were editing the resource
LeandroFerreira
LeandroFerreiraβ€’4mo ago
where are you rendering your blade component?
Twixzor
TwixzorOPβ€’4mo ago
in the filament dashboard page
LeandroFerreira
LeandroFerreiraβ€’4mo ago
would you like to open a modal resource from your dashboard, right? Using a custom button, for example?
Twixzor
TwixzorOPβ€’4mo ago
I don't want to use a button, but a calendar with dates, if I click on a date I want to edit it, if there is space then create a new one :S
LeandroFerreira
LeandroFerreiraβ€’4mo ago
I believe you have a simple resource, using modals to create/edit records. In your ManageXX.php page, add this:
use Filament\Support\Facades\FilamentView;
use Filament\View\PanelsRenderHook;
use Livewire\Attributes\Url;

#[Url]
public ?string $action = null;

#[Url]
public string $action_id = '0';

public function mount(): void
{
parent::mount();

FilamentView::registerRenderHook(
PanelsRenderHook::PAGE_END,
fn (): string => '<div wire:init="init"></div>',
);
}

public function init(): void
{
if ($this->action === 'edit') {
$this->mountTableAction('edit', $this->action_id);
}
}
use Filament\Support\Facades\FilamentView;
use Filament\View\PanelsRenderHook;
use Livewire\Attributes\Url;

#[Url]
public ?string $action = null;

#[Url]
public string $action_id = '0';

public function mount(): void
{
parent::mount();

FilamentView::registerRenderHook(
PanelsRenderHook::PAGE_END,
fn (): string => '<div wire:init="init"></div>',
);
}

public function init(): void
{
if ($this->action === 'edit') {
$this->mountTableAction('edit', $this->action_id);
}
}
Then, redirect to this page using url params: /admin/xxx?action=create /admin/xxx?action=edit&action_id=1
Twixzor
TwixzorOPβ€’4mo ago
thank you! i will check πŸ™ I'm new to laravel, I've been following it for a long time, but I've only just decided to give it a try, filament gave me the final push, because with it I can probably progress faster in my work than with my self-developed admin interface Unfortunately it's not what i wan, because I don't want to open the modal with a redirect, but with an Ajax request, triggered by a JavaScript event. 😦
Hung Thai
Hung Thaiβ€’4mo ago
Up. I'm looking for the same effect but haven't found any yet.
Twixzor
TwixzorOPβ€’4mo ago
I didn't find a solution, so I redirect it to the resource edit and create page on click
Want results from more Discord servers?
Add your server