I have in UserResource file this static method
public static function getBlockedUserFrom(User $record): array
{
return [
Forms\Components\Toggle::make('is_blocked')
->label(__('Order Blocked')),
Forms\Components\Textarea::make('blocked_message')
->label(__('Blocked Message'))
];
}
And in the EditUser file I have this method:
protected function getActions(): array
{
return array_merge(parent::getActions(), [
ButtonAction::make('block')
->label(__('Block User'))
->color('danger')
->action(function (array $data) {
$this->record->update([
'is_blocked' => $data['is_blocked'],
'blocked_message' => $data['blocked_message'],
]);
})
->form(UserResource::getBlockedUserFrom($this->record))
->requiresConfirmation(),
]);
}
Basically, this creates a modal in the edit user page ...
I need to put a value in blocked_message that the user already did, cuz now when I add a message and then open the modal again the blocked_message input is empty even if the message exists in DB,