PHPackages                             yodaylay22/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. [Templating &amp; Views](/categories/templating)
4. /
5. yodaylay22/filament-ptbr-form-fields

ActiveLibrary[Templating &amp; Views](/categories/templating)

yodaylay22/filament-ptbr-form-fields
====================================

Brazilian pt-BR form fields.

3.0.9(1y ago)052MITPHPPHP ^8.1 || ^8.2

Since Apr 25Pushed 1y agoCompare

[ Source](https://github.com/yodaylay22/filament-ptbr-form-fields)[ Packagist](https://packagist.org/packages/yodaylay22/filament-ptbr-form-fields)[ Docs](https://github.com/leandrocfe/filament-ptbr-form-fields)[ RSS](/packages/yodaylay22-filament-ptbr-form-fields/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (14)Versions (18)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/v3-example.png)](https://raw.githubusercontent.com/leandrocfe/filament-ptbr-form-fields/develop/screenshots/v3-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 format() method with a string argument representing the desired format:

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

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

### Money

[](#money)

To create a money input with the Brazilian currency symbol as the prefix, use:

```
use Leandrocfe\FilamentPtbrFormFields\Money;
Money::make('price')
```

If you want to remove the prefix, use the prefix() method with a null argument:

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

By default, the mask is removed from the input when it is submitted. If you want to keep the mask, use the dehydrateMask() method with a false argument:

```
Money::make('price')
->dehydrateMask(false)
```

The initial value of the input is '0,00'. If you want to change the initial value, use the initialValue() method with a string argument:

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

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

32

—

LowBetter than 69% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 53% 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 ~43 days

Recently: every ~36 days

Total

12

Last Release

690d ago

Major Versions

0.1.0 → 3.0.02023-08-15

2.0.0 → 3.0.12023-08-30

PHP version history (2 changes)0.1.0PHP ^8.1

3.0.5PHP ^8.1 || ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12820569?v=4)[Yuri Eloi](/maintainers/Yodaylay22)[@yodaylay22](https://github.com/yodaylay22)

---

Top Contributors

[![leandrocfe](https://avatars.githubusercontent.com/u/3833889?v=4)](https://github.com/leandrocfe "leandrocfe (35 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)")[![yodaylay22](https://avatars.githubusercontent.com/u/12820569?v=4)](https://github.com/yodaylay22 "yodaylay22 (4 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)")

---

Tags

laravelleandrocfefilament-ptbr-form-fields

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17760.2k3](/packages/stephenjude-filament-jetstream)[stephenjude/filament-debugger

About

104162.2k2](/packages/stephenjude-filament-debugger)[croustibat/filament-jobs-monitor

Background Jobs monitoring like Horizon for all drivers for FilamentPHP

274326.6k8](/packages/croustibat-filament-jobs-monitor)[finity-labs/fin-mail

A powerful email template manager and composer for Filament with dynamic token replacement, template versioning, and inline email sending.

284.5k1](/packages/finity-labs-fin-mail)

PHPackages © 2026

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