#Help with action modal

9 messages · Page 1 of 1 (latest)

empty berry
#

Hi everyone,

I'm trying to have a action modal rendered via a panel render hook, but I can't seem to get the action to do anything. Trying multiple YouTube videos/tutorials, it's not even giving me an error, just not doing anything.

Livewire component:

class SwitchHotels extends Component implements HasActions, HasForms
{
    use InteractsWithActions;
    use InteractsWithForms;

    public function renderHotelSwitch()
    {
        return Action::make('switchHotel')
            ->label('Switch Hotel')
            ->icon('heroicon-m-building-office-2')
            ->form([
                Select::make('hotel_id')
                    ->label('Switch Hotel')
                    ->options(function () {
                        return Hotel::pluck('name', 'id')->toArray();
                    })
                    ->required()
            ])
            ->action(function (array $data): void {
                $hotel = Hotel::findOrFail($data['hotel_id']);

                auth()->user()->update([
                    'current_hotel_id' => $hotel->id
                ]);

                $this->redirect(request()->header('Referer'));
            });
    }

    public function render()
    {
        return view('livewire.switch-hotels');
    }
}

And How I render it:

        FilamentView::registerRenderHook(PanelsRenderHook::GLOBAL_SEARCH_AFTER, function() {
            return Blade::render("<livewire:switch-hotels />");
        });

Any help appreciated.

#

Also the view:

#
<div>
    {{ $this->renderHotelSwitch() }}

    <x-filament-actions::modals />
</div>
tender yew
empty berry
#

Ayyy lmao that worked

#

Probably missed that magic in the documentation?

#

I'll double check, if not I'll send PR to update docs

empty berry
#

I guess I'm just bad at reading documentation. Thanks a lot friend!