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
LeandroFerreira7mo ago
$record , $this->getRecord() ?
Unsociable
Unsociable7mo ago
Thanks! Is it possible to refresh the view page where the button was pressed when completed?
LeandroFerreira
LeandroFerreira7mo ago
Isn't it happening?
Unsociable
Unsociable7mo 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
LeandroFerreira7mo ago
what is the issue?
Unsociable
Unsociable7mo ago
Does refreshFormData update the view form of the model? It doesn't seem to but a page reload does
LeandroFerreira
LeandroFerreira7mo 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
Unsociable7mo ago
Thanks for the help that helped a lot!