Comments (8)
Estou com o mesmo problema do @mclgms , é sempre adicionado um 0 a cada edit feito no registro
from filament-ptbr-form-fields.
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;
}
}
from filament-ptbr-form-fields.
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
from filament-ptbr-form-fields.
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 $value
as vezes vem estranha, exemplo: R$ 200,00 no input, a variável $rule está como '0,200' na Closure.
from filament-ptbr-form-fields.
@mclgms , pode por favor verificar a ultima atualização e dizer se o problema resolveu?
Obrigado!
from filament-ptbr-form-fields.
from filament-ptbr-form-fields.
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 valueasvezesvemestranha,exemplo:R 200,00 no input, a variável $rule está como '0,200' na Closure.
@mtbossa
Por favor, abra uma nova issue pra gente verificar. Obrigado!
from filament-ptbr-form-fields.
Estou tendo o mesmo problema agora, versão atualizada.
from filament-ptbr-form-fields.
Related Issues (10)
- [Bug]: HOT 3
- Atualização para o filament v3 HOT 6
- [Bug]: Utilização do componente Money em live() com Placeholder HOT 4
- [Bug]: Money mask change value after load file with FileUpload
- [Bug]: minValue not work
- [Bug]: Salvando campo money com 0,00 mesmo quando nada é preenchido. HOT 6
- [Bug]: cpf only field return CPF + CNPJ validation message error
- [Bug]: cpf_or_cnpj field is not saving properly on the database
- [Bug]: Problema no component Money HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filament-ptbr-form-fields.