injecting view data to action

I have an action::make inside a ViewRecord under getHeaderActions() I have a ->disabled() value but want to pickup the model data to set this. I have tried disabled(function ($data)) and also $arguments but these are both empty.
8 Replies
LeandroFerreira
LeandroFerreira12mo ago
$record , $this->getRecord() ?
Unsociable
UnsociableOP12mo ago
Thanks! Is it possible to refresh the view page where the button was pressed when completed?
LeandroFerreira
LeandroFerreira12mo ago
Isn't it happening?
Unsociable
UnsociableOP12mo ago
So I am saving the updated record to the DB and sending this with refreshFormData as an array. I am also sending the notification which is being sent. So inside the action I have $this->refreshFormData($array) Which is a correct array
LeandroFerreira
LeandroFerreira12mo ago
what is the issue?
Unsociable
UnsociableOP12mo ago
Does refreshFormData update the view form of the model? It doesn't seem to but a page reload does
LeandroFerreira
LeandroFerreira12mo ago
are you doing something like this?
Action::make('custom-action')
->action(function () {
$this->record->update([
'field' => 'new value',
]);
$this->refreshFormData(['field']);
})
Action::make('custom-action')
->action(function () {
$this->record->update([
'field' => 'new value',
]);
$this->refreshFormData(['field']);
})
refreshFormData isn't necessary if you are using an infolist
Unsociable
UnsociableOP12mo ago
Thanks for the help that helped a lot!
Want results from more Discord servers?
Add your server