Custom action on edit resource

On a custom action on an edit resource I'm changing a field on that resource. But I'm having 2 problems: 1 - That field is changing on the BD, but the UI is not updating. 2 - The notification is not working.
No description
6 Replies
Hasith
Hasith15mo ago
Use $set and assign new value to it
->action(function (Set $set,User $record)
{
$set('field_name', $new_value);
})
->action(function (Set $set,User $record)
{
$set('field_name', $new_value);
})
Notification::make()->success()->title('message')->send();
Notification::make()->success()->title('message')->send();
You have to send the notification at the end
Diogo Gomes
Diogo GomesOP15mo ago
Oh thank you for that send() tip 🤦‍♂️
Diogo Gomes
Diogo GomesOP15mo ago
I've tried the set but I'm getting this error
No description
Diogo Gomes
Diogo GomesOP15mo ago
This is for an EditRecord page
Hasith
Hasith15mo ago
Try adding this inside the action
$this->refreshFormData([
'status',
]);
$this->refreshFormData([
'status',
]);
i hope this will work @diogogomes
Diogo Gomes
Diogo GomesOP15mo ago
Oh perfect! Yes, it does work. Thank you so much @Hasith
Want results from more Discord servers?
Add your server