F
Filament16mo ago
Zakhaev

Problem with decimal format (EUR) (,)

Hello im using this mask function to format the input field to give me the exact format how i want it.
TextInput::make('final_price')
->label('Uiteindelijke kosten (excl. btw)')
->numeric()
->mask(fn(Forms\Components\TextInput\Mask $mask) => $mask
->patternBlocks([
'money' => fn (Mask $mask) => $mask
->numeric()
->thousandsSeparator('.')
->decimalSeparator(',')
->decimalPlaces(2)
->padFractionalZeros()
->normalizeZeros(false),
])
->pattern("€ money")
TextInput::make('final_price')
->label('Uiteindelijke kosten (excl. btw)')
->numeric()
->mask(fn(Forms\Components\TextInput\Mask $mask) => $mask
->patternBlocks([
'money' => fn (Mask $mask) => $mask
->numeric()
->thousandsSeparator('.')
->decimalSeparator(',')
->decimalPlaces(2)
->padFractionalZeros()
->normalizeZeros(false),
])
->pattern("€ money")
this is working fine, but the problem is when i save it. The database has a decimal field. if i save the field [1st picture] 1500 and the 2nd picture is after i saved it 150.000 I know this has to do with the formatting but i couldnt found a way to fix this, can anyone help me.
Solution:
``` protected function MaximumPriceExcVat(): Attribute { return Attribute::make( get: fn ($value) => price($value,2),...
Jump to solution
11 Replies
Andrew Wallo
Andrew Wallo16mo ago
Yes EUR format for mask in v2 doesn’t work. This is a known issue. The mask in v2 has a lot of issues
Zakhaev
ZakhaevOP16mo ago
oh alright is there a way to manipulate the data before the form is submitting it? maybe i can change it
bernhard
bernhard16mo ago
Dehydration is the process which gets data from fields, and transforms it. TextInput::make('name')->dehydrateStateUsing(fn ($state) => ucwords($state))
Andrew Wallo
Andrew Wallo16mo ago
No probably not because the data has to be numeric I tried this many times in v2 But if you find a way let me know The data will be submitted correctly it’s just the formatting for the mask that’s wrong
Zakhaev
ZakhaevOP16mo ago
Hi guys, im still stuck with this problem i found this method but it doesnt change anything for me
public function getMaximumPriceExcVatCentsAttribute()
{
return $this->maximum_price_exc_vat * 100;


}

public function setMaximumPriceExcVatCentsAttribute($value)
{
return $this->maximum_price_exc_vat / 100;
}
public function getMaximumPriceExcVatCentsAttribute()
{
return $this->maximum_price_exc_vat * 100;


}

public function setMaximumPriceExcVatCentsAttribute($value)
{
return $this->maximum_price_exc_vat / 100;
}
this is in my model can i use the get/set attribute magic functions? im trying to use this
Zakhaev
ZakhaevOP16mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Zakhaev
ZakhaevOP16mo ago
nevermind i fixed it in the model i use this
Solution
Zakhaev
Zakhaev16mo ago
protected function MaximumPriceExcVat(): Attribute
{
return Attribute::make(
get: fn ($value) => price($value,2),
);
}
protected function MaximumPriceExcVat(): Attribute
{
return Attribute::make(
get: fn ($value) => price($value,2),
);
}
Zakhaev
ZakhaevOP16mo ago
@Andrew Wallo found a way, i put the solution above this reply
Andrew Wallo
Andrew Wallo16mo ago
Hmm okay thanks
Want results from more Discord servers?
Add your server