leandrocfe / filament-ptbr-form-fields

This package provides custom form fields for Filament (>=v2.17.28) that are commonly used in Brazilian web applications, such as CPF/CNPJ validation, phone number formatting, money with currency symbol, and CEP integration with ViaCep.
MIT License
97 stars 17 forks source link

[Bug]: cpf_or_cnpj field is not saving properly on the database #18

Open BRGustavoRibeiro opened 7 months ago

BRGustavoRibeiro commented 7 months ago

What happened?

I expected _cpf_orcnpj field to save data on the database without the mask, and the dehydrateMask() method should be available in case I wanted to save the info with the mask.

How to reproduce the bug

Fill a _cpf_orcnpj field. Save it. Check it on the database - it is saved as 111.111.111-11 instead of 11111111111

Package Version

3.0.1

PHP Version

8.2.0

Laravel Version

10.3.3

Which operating systems does with happen with?

Windows

Notes

No response

bianchi commented 3 months ago

Tenho o mesmo problema, resolvi adicionando no meu EditCustomer o seguinte:

protected function mutateFormDataBeforeSave(array $data): array
{
        $data['document_number'] = preg_replace('/\D/', '', $data['document_number']);

        return $data;
}