-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Componente Money não está atualizandocorretamente os valores no Banco - Filament V3. #9
Comments
O bug também acontece uilizando MoneyCast (https://filamentphp.com/docs/3.x/panels/getting-started#casting-the-price-to-an-integer) e salvando como integer no banco. Segue vídeo com teste: Gravacao.de.tela.de.2023-08-24.14-27-46.webm |
Eu queria saber como adicionar uma rule de valor mínimo. Tentei utilizar o 'min:1' do Laravel, ou o min() do Filament, mas nenhum funciona (nada acontece). A única forma que eu encontrei foi fazer um minLength() com o valor mínimo de caracteres. Tentei adicionar uma custom rule com Closure, mas a variável |
@mclgms , pode por favor verificar a ultima atualização e dizer se o problema resolveu? |
Leandro, bom dia.
Sim, resolveu.
Muito obrigado!
Atenciosamente
Marcelo Gomes | MG Consultoria e Serviços de TI
Fixo : (11) 2214-3585 / Móvel: (11) 9 8364-3775
…------ Mensagem original ------
De "Leandro Costa Ferreira" ***@***.***>
Para "leandrocfe/filament-ptbr-form-fields"
***@***.***>
Cc "Marcelo Gomes" ***@***.***>; "Mention"
***@***.***>
Data 30/08/2023 15:08:22
Assunto Re: [leandrocfe/filament-ptbr-form-fields] [Bug]: Componente
Money não está atualizandocorretamente os valores no Banco - Filament
V3. (Issue #9)
@mclgms <https://github.com/mclgms> , pode por favor verificar a ultima
atualização e dizer se o problema resolveu?
Obrigado!
—
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE3FR6VXF7DORIIFA53YATLXX56RNANCNFSM6AAAAAA35HMZKQ>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@mtbossa |
Estou com o mesmo problema do @mclgms , é sempre adicionado um 0 a cada edit feito no registro |
Eu fiz algumas atualizacoes locais e me parece estar tudo ok, para quem quiser criar manualmente o field: <?php
namespace App\Forms\Components;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
class Money extends TextInput
{
protected string|int|float|null $initialValue = '0,00';
protected function setUp(): void
{
$this
->prefix('R$')
->maxLength(13)
->extraAlpineAttributes([
'x-mask:dynamic' => '$money($input, ",", ".", 2)'
])
->prefix('R$')
->maxLength(13)
->dehydrateMask()
->default(0.00)
->formatStateUsing(fn($state) => $state ? number_format(floatval($state), 2, ',', '.') : $this->initialValue);
}
public function dehydrateMask(bool|\Closure $condition = true): static
{
if ($condition) {
$this->dehydrateStateUsing(
fn($state): ?float => $state ?
floatval(
Str::of($state)
->replace('.', '')
->replace(',', '.')
->toString()
) :
null
);
} else {
$this->dehydrateStateUsing(null);
}
return $this;
}
public function initialValue(null|string|int|float|\Closure $value = '0,00'): static
{
$this->initialValue = $value;
return $this;
}
} |
What happened?
O componente Money ao salvar o registro durante a criação está salvando o dado corretamente.
Na edição, ele acrescenta "0" no valor original.
***Exemplo:
How to reproduce the bug
Package Version
3.0.0
PHP Version
8.2
Laravel Version
10.20.0
Which operating systems does with happen with?
Linux
Notes
No banco o campo foi definido como: decimal(10,2)
The text was updated successfully, but these errors were encountered: