PHPackages                             proho/filament-ptbr-form-fields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. proho/filament-ptbr-form-fields

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

proho/filament-ptbr-form-fields
===============================

Brazilian pt-BR form fields.

3.1.0(1y ago)0106MITPHPPHP ^8.1 || ^8.2 || ^8.3

Since Apr 25Pushed 4mo agoCompare

[ Source](https://github.com/prohonoski/filament-ptbr-form-fields)[ Packagist](https://packagist.org/packages/proho/filament-ptbr-form-fields)[ Docs](https://github.com/leandrocfe/filament-ptbr-form-fields)[ RSS](/packages/proho-filament-ptbr-form-fields/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (16)Versions (30)Used By (0)

Brazilian pt-BR form fields.
============================

[](#brazilian-pt-br-form-fields)

This package provides custom form fields for [Filament](https://filamentphp.com/) 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](https://viacep.com.br).

This package uses [LaravelLegends/pt-br-validator](https://github.com/LaravelLegends/pt-br-validator) to validate Brazilian Portuguese fields.

[![image demo](https://raw.githubusercontent.com/leandrocfe/filament-ptbr-form-fields/develop/screenshots/v3x-example.png)](https://raw.githubusercontent.com/leandrocfe/filament-ptbr-form-fields/develop/screenshots/v3x-example.png)

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require leandrocfe/filament-ptbr-form-fields:"^3.0"
```

### Filament V2 - if you are using Filament v2.x, you can use [this section](https://github.com/leandrocfe/filament-ptbr-form-fields/tree/2.0.0)

[](#filament-v2---if-you-are-using-filament-v2x-you-can-use-this-section)

Usage
-----

[](#usage)

### CPF / CNPJ

[](#cpf--cnpj)

To create a dynamic input that accepts either CPF or CNPJ, use:

```
use Leandrocfe\FilamentPtbrFormFields\Document;
//CPF or CNPJ
Document::make('cpf_or_cnpj')
    ->dynamic()
```

If you want to create an input that only accepts CPF or only accepts CNPJ, use:

```
//CPF
Document::make('cpf')
    ->cpf()
```

```
//CNPJ
Document::make('cnpj')
    ->cnpj()
```

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:

```
Document::make('cpf')
    ->cpf('999999999-99')
```

```
Document::make('cnpj')
    ->cnpj('99999999/9999-99')
```

### Validation

[](#validation)

`Document` uses [LaravelLegends/pt-br-validator](https://github.com/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:

```
Document::make('cpf_or_cnpj')
    ->validation(false)
    ->dynamic()
```

```
Document::make('cpf')
    ->validation(false)
    ->cpf()
```

### Phone number

[](#phone-number)

To create a dynamic input that formats phone numbers with DDD, use:

```
use Leandrocfe\FilamentPtbrFormFields\PhoneNumber;
PhoneNumber::make('phone_number')
```

If you want to use a custom phone number format, use the `mask() method with a string argument representing the desired format:

```
PhoneNumber::make('phone_number')
    ->mask('(99) 99999-9999')
```

```
PhoneNumber::make('phone_number')
    ->mask('+99 (99) 99999-9999')
```

### Money

[](#money)

To create a money input field, use the following syntax:

```
use Leandrocfe\FilamentPtbrFormFields\Money;
Money::make('price')
    ->default('100,00')

#output: 100.00
```

This is suitable for use with `decimal` or `float` data types.

#### Using Integer Values

[](#using-integer-values)

If you prefer to work with integer values, you can format the money input using the `intFormat()` method:

```
use Leandrocfe\FilamentPtbrFormFields\Money;
Money::make('price')
    ->default(10000)
    ->intFormat()

#output: 10000
```

#### Getting the Raw State

[](#getting-the-raw-state)

To retrieve the raw state of the field, you can use the `dehydratedMask() method:

```
use Leandrocfe\FilamentPtbrFormFields\Money;
Money::make('price')
    ->default('100,00')
    ->dehydrateMask()

#output: 100,00
```

If you need to remove the prefix from the money input, simply pass null to the `prefix()` method:

```
Money::make('price')
    ->prefix(null)
```

#### Currency Formatting

[](#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:

```
use Leandrocfe\FilamentPtbrFormFields\Currencies\USD;

Money::make('price')
    ->currency(USD::class)
    ->prefix('$')
```

You can also define custom currencies to suit your specific needs:

```
/*
 * app/Currencies/EUR.php
 */

declare(strict_types=1);

namespace App\Currencies;

use ArchTech\Money\Currency;

class EUR extends Currency
{
    /*
     * Code of the currency.
     */
    public string $code = 'EUR';

    /*
     * Name of the currency.
     */
    public string $name = 'Euro';

    /*
     * Rate of this currency relative to the default currency.
     */
    public float $rate = 1.0;

    /*
     * Number of decimals used in money calculations.
     */
    public int $mathDecimals = 2;

    /*
     * Number of decimals used in the formatted value
     */
    public int $displayDecimals = 2;

    /*
     * How many decimals of the currency's values should get rounded
     */
    public int $rounding = 2;

    /*
     * Prefix placed at the beginning of the formatted value.
    */
    public string $prefix = '€';

    /*
     * The language code.
     */
    public string $locale = 'pt';

    /*
     * The character used to separate the decimal values.
     */
    public string $decimalSeparator = '.';

    /*
     * The character used to separate groups of thousands
     */
    public string $thousandsSeparator = ',';
}
```

```
use App\Currencies\EUR;

Money::make('price')
->currency(EUR::class)
->prefix('€')
```

### Address

[](#address)

To integrate with the ViaCep API for CEP validation and address autofill, use:

```
use Leandrocfe\FilamentPtbrFormFields\Cep;
use Filament\Forms\Components\TextInput;
Cep::make('postal_code')
    ->viaCep(
        mode: 'suffix', // Determines whether the action should be appended to (suffix) or prepended to (prefix) the cep field, or not included at all (none).
        errorMessage: 'CEP inválido.', // Error message to display if the CEP is invalid.

        /**
         * Other form fields that can be filled by ViaCep.
         * The key is the name of the Filament input, and the value is the ViaCep attribute that corresponds to it.
         * More information: https://viacep.com.br/
         */
        setFields: [
            'street' => 'logradouro',
            'number' => 'numero',
            'complement' => 'complemento',
            'district' => 'bairro',
            'city' => 'localidade',
            'state' => 'uf'
        ]
    ),

TextInput::make('street'),
TextInput::make('number'),
TextInput::make('complement'),
TextInput::make('district'),
TextInput::make('city'),
TextInput::make('state'),
```

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

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within this package, please send an e-mail to .

Credits
-------

[](#credits)

- [Leandro Costa Ferreira](https://github.com/leandrocfe)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance56

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 61.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~42 days

Recently: every ~89 days

Total

24

Last Release

149d ago

Major Versions

0.1.0 → 3.0.02023-08-15

2.0.0 → 3.0.12023-08-30

2.1.3 → 3.1.02024-08-30

PHP version history (3 changes)0.1.0PHP ^8.1

3.0.5PHP ^8.1 || ^8.2

2.0.3PHP ^8.1 || ^8.2 || ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30838784?v=4)[prohonoski](/maintainers/prohonoski)[@prohonoski](https://github.com/prohonoski)

---

Top Contributors

[![leandrocfe](https://avatars.githubusercontent.com/u/3833889?v=4)](https://github.com/leandrocfe "leandrocfe (44 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![rmsramos](https://avatars.githubusercontent.com/u/5170473?v=4)](https://github.com/rmsramos "rmsramos (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![patriciomartinns](https://avatars.githubusercontent.com/u/20000058?v=4)](https://github.com/patriciomartinns "patriciomartinns (3 commits)")[![danielcei](https://avatars.githubusercontent.com/u/19355609?v=4)](https://github.com/danielcei "danielcei (2 commits)")[![prohonoski](https://avatars.githubusercontent.com/u/30838784?v=4)](https://github.com/prohonoski "prohonoski (1 commits)")

---

Tags

laravelleandrocfefilament-ptbr-form-fields

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/proho-filament-ptbr-form-fields/health.svg)

```
[![Health](https://phpackages.com/badges/proho-filament-ptbr-form-fields/health.svg)](https://phpackages.com/packages/proho-filament-ptbr-form-fields)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[leandrocfe/filament-ptbr-form-fields

Brazilian pt-BR form fields.

14398.7k](/packages/leandrocfe-filament-ptbr-form-fields)[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

206120.5k1](/packages/guava-filament-knowledge-base)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[bezhansalleh/filament-plugin-essentials

A collection of essential traits that streamline Filament plugin development by taking care of the boilerplate, so you can focus on shipping real features faster

27584.7k16](/packages/bezhansalleh-filament-plugin-essentials)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
