F
Filament5mo ago
Xavi

Refresh field after modal form

I want to refresh field after modal form, but i don't know how? Anyone can helpme? Its my code:
TextInput::make('deposit')
->label(__('Saldo'))
->formatStateUsing(fn(User $user) => $user->getWallet()->balance)
->disabled()
->suffixAction(
Action::make('updateDeposit')
->label(__('Actualizar saldo'))
->icon('heroicon-m-clipboard')
->form([
TextInput::make('amount')
->label(__('Cantidad'))
->required()
->numeric(),
TextInput::make('description')
->required()
->label(__('Descripción'))
])
->action(function ($action, array $data, User $record): void {
$walletService = new WalletService($record);

if ($data['amount'] > 0) {
$walletService->deposit($data['amount'], $data['amount']);
}

if ($data['amount'] < 0) {
$walletService->withdraw($data['amount'], -$data['amount']);
}

Notification::make()
->title(__('Saldo actualizado'))
->body(__('El saldo se ha actualizado correctamente'))
->send();
})

),
TextInput::make('deposit')
->label(__('Saldo'))
->formatStateUsing(fn(User $user) => $user->getWallet()->balance)
->disabled()
->suffixAction(
Action::make('updateDeposit')
->label(__('Actualizar saldo'))
->icon('heroicon-m-clipboard')
->form([
TextInput::make('amount')
->label(__('Cantidad'))
->required()
->numeric(),
TextInput::make('description')
->required()
->label(__('Descripción'))
])
->action(function ($action, array $data, User $record): void {
$walletService = new WalletService($record);

if ($data['amount'] > 0) {
$walletService->deposit($data['amount'], $data['amount']);
}

if ($data['amount'] < 0) {
$walletService->withdraw($data['amount'], -$data['amount']);
}

Notification::make()
->title(__('Saldo actualizado'))
->body(__('El saldo se ha actualizado correctamente'))
->send();
})

),
Thanks
2 Replies
Matthew
Matthew5mo ago
What do you mean refresh? After modal submission, it will close, and when you reopen it's "refrfeshed" anyways Or maybe I didnt understand what you meant 😅
Xavi
Xavi5mo ago
jeje sorry. When i change amount after modal submission, field deposit it's not changed, i must to refresh page to see the changes