F
Filament11mo ago
KeyMe

Replace mounted action passing arguments

After executing one of my custom page action, I replace it with another action passing along arguments, but when I tried to die n dumped it in the send email action class it returned null. Could someone tell me what I'm doing wrong? The $data array wasn't null in after() method. ViewOrder.php
protected function getActions(): array
{
return [
PostService::make()
->after(function (array $data) {
if ($this->record->training->status()->is('Training Arranged')) {
$this->replaceMountedAction('sendEmail', $data);
}
}),
];
}

public function sendEmail() { return SendEmail::make();}
protected function getActions(): array
{
return [
PostService::make()
->after(function (array $data) {
if ($this->record->training->status()->is('Training Arranged')) {
$this->replaceMountedAction('sendEmail', $data);
}
}),
];
}

public function sendEmail() { return SendEmail::make();}
SendEmail.php
class SendEmail extends Action
{
public static function getDefaultName(): ?string
{
return 'sendEmail';
}

protected function setUp(): void
{
parent::setUp();
dd($this->arguments);
}
class SendEmail extends Action
{
public static function getDefaultName(): ?string
{
return 'sendEmail';
}

protected function setUp(): void
{
parent::setUp();
dd($this->arguments);
}
1 Reply
KeyMe
KeyMeOP11mo ago
I can access the passed arguments by defining $arguments param in closure functions, but i wanted to see if i can access it outside of form/action methods etc.
Want results from more Discord servers?
Add your server