Download the PHP package leandrocfe/filament-ptbr-form-fields without Composer
On this page you can find all versions of the php package leandrocfe/filament-ptbr-form-fields. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leandrocfe/filament-ptbr-form-fields
More information about leandrocfe/filament-ptbr-form-fields
Files in leandrocfe/filament-ptbr-form-fields
Package filament-ptbr-form-fields
Short Description Brazilian pt-BR form fields.
License MIT
Homepage https://github.com/leandrocfe/filament-ptbr-form-fields
Informations about the package filament-ptbr-form-fields
Brazilian pt-BR form fields.
This package provides custom form fields for Filament 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.
This package uses LaravelLegends/pt-br-validator to validate Brazilian Portuguese fields.
Installation
You can install the package via Composer:
Filament V2 - if you are using Filament v2.x, you can use this section
Usage
CPF / CNPJ
To create a dynamic input that accepts either CPF or CNPJ, use:
If you want to create an input that only accepts CPF or only accepts CNPJ, use:
If you want to use a custom mask for the input, use the cpf() or cnpj() method with a string argument representing the desired mask:
Validation
Document
uses LaravelLegends/pt-br-validator to validate Brazilian Portuguese fields by default - cpf_ou_cnpj
| cpf
| cnpj
You can disable validation using the validation(false)
method:
Phone number
To create a dynamic input that formats phone numbers with DDD, use:
If you want to use a custom phone number format, use the `mask() method with a string argument representing the desired format:
Money
To create a money input field, use the following syntax:
This is suitable for use with decimal
or float
data types.
Using Integer Values
If you prefer to work with integer values, you can format the money input using the intFormat()
method:
Getting the Raw State
To retrieve the raw state of the field, you can use the `dehydratedMask() method:
If you need to remove the prefix from the money input, simply pass null to the prefix()
method:
Currency Formatting
This package leverages the archtechx/money
package under the hood. By default, it uses the BRL
(Brazilian Real) format for currency values.
If you want to switch to the USD
(United States Dollar) format, you can do so with the following code:
You can also define custom currencies to suit your specific needs:
Address
To integrate with the ViaCep API for CEP validation and address autofill, use:
The mode parameter specifies whether the search action should be appended to or prepended to the CEP field, using the values suffix or prefix. Alternatively, you can use the none value with the ->live(onBlur: true)
method to indicate that the other address fields will be automatically filled only when the CEP field loses focus.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover a security vulnerability within this package, please send an e-mail to [email protected].
Credits
- Leandro Costa Ferreira
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of filament-ptbr-form-fields with dependencies
archtechx/money Version ^0.5.1
filament/filament Version ^3.0
illuminate/contracts Version ^10.0 || ^11.0
laravellegends/pt-br-validator Version ^10.0 || ^11.0
moneyphp/money Version ^4.5
spatie/laravel-package-tools Version ^1.14.0