awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
343 stars 89 forks source link

Fix: remove lazy attribute for panel #388

Closed awcodes closed 11 months ago

awcodes commented 11 months ago

Fixes console error about form data not being found when opening other modals.

MtDalPizzol commented 11 months ago

This introduced a problem:

When using a custom MediaAction that injects the form model as $record, the record is always null|undefined.

<?php

class MediaAction extends Action
{
    public static function getDefaultName(): ?string
    {
        return 'filament_tiptap_media';
    }

    protected function setUp(): void
    {
        parent::setUp();

        $this
            ->arguments([
                'src' => '',
            ])
            ->action(function (
                  TiptapEditor|CuratorPicker $component,
                  Component $livewire,
                  array $arguments,
                  Model $record // <-- this used to work just fine
            ) { 
                // ...
            });
    }
}
awcodes commented 11 months ago

I don't see what effect the Lazy attribute would have on dependency injection.

Does $livewire->getRecord() give you the record?