F
Filament9mo ago
KeyMe

Accessing reference to calling object from action class

I created an action class that extends the original action, override setUp(), and called it from a resource viewrecord page. How do i inject viewrecord instance so that I can call its' fillForm() to refresh the page once the action is performed? class ReviseUserDetail extends Actions\Action
protected function setUp(): void
{
parent::setUp();

$this
->form(OrderResource::getCustomerDetails())
->fillForm($this->record->attributesToArray())
->action(function (array $data): void {
$this->record->update($data);
Notification::make()
->title('Saved successfully!')
->success()
->send();
})
protected function setUp(): void
{
parent::setUp();

$this
->form(OrderResource::getCustomerDetails())
->fillForm($this->record->attributesToArray())
->action(function (array $data): void {
$this->record->update($data);
Notification::make()
->title('Saved successfully!')
->success()
->send();
})
5 Replies
KeyMe
KeyMe9mo ago
for now i did it by calling fillForm() in the after() method, but i still wonder if its possible to do it from the action class itself. class ViewOrder extends ViewRecord
ReviseUserDetail::make()
->after(fn() => $this->fillForm()),
ReviseUserDetail::make()
->after(fn() => $this->fillForm()),
DrByte
DrByte9mo ago
GitHub
filament/packages/tables/src/Actions/ViewAction.php at 954e9640953d...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
KeyMe
KeyMe9mo ago
tried following the source for actions EditAction, it only fills the form with data, but doesn't refresh the main page
DrByte
DrByte9mo ago
Apologies: I don't have a better answer ... yet. I'm going to need to do something similar in an app I'm working on, but there's another milestone to finish first before I have to tackle that one.
KeyMe
KeyMe9mo ago
no worries, do provide a follow up if u figure somth out hehe.