filament-ptbr-form-fields icon indicating copy to clipboard operation
filament-ptbr-form-fields copied to clipboard

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

Open BRGustavoRibeiro opened this issue 1 year ago • 2 comments

What happened?

I expected cpf_or_cnpj 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_or_cnpj 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

BRGustavoRibeiro avatar Mar 09 '24 00:03 BRGustavoRibeiro

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;
}

bianchi avatar Jun 20 '24 19:06 bianchi

O ideal seria fazer isso no Model, não?

lucasff avatar Nov 15 '24 16:11 lucasff