F
Filament6mo ago
gremki

How to get page reference from resource

Hello! I have a set of pages (list/create/edit) that have url attribute, something like
#[Url]
public ?string $parent_id = null;
#[Url]
public ?string $parent_id = null;
How can access this attribute from methods in corresponding resource? (In form or table methods) I'm sorry if this is a dumb question, but I'm pretty new in Livewire and Filament ecosystem.
Solution:
Thanks a lot! That pointed me in the right direction. Also, there is even a simpler way, there is a getLivewire() available on table and form components:
$table->getLivewire()->parent_id
$table->getLivewire()->parent_id
...
Jump to solution
2 Replies
Tetracyclic
Tetracyclic6mo ago
You can access the current page object using the $livewire hint on supported Filament closures: https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-current-livewire-component-instance You can then use PHP's ReflectionObject to inspect the attributes on that $livewire compoonent
Solution
gremki
gremki6mo ago
Thanks a lot! That pointed me in the right direction. Also, there is even a simpler way, there is a getLivewire() available on table and form components:
$table->getLivewire()->parent_id
$table->getLivewire()->parent_id
Want results from more Discord servers?
Add your server