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 1mo ago

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 72% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

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

644d 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://www.gravatar.com/avatar/bb8b717ed1185a1d1e0d5358a1a9b34612b50203f431d037c8e1cad18aaf3a25?d=identicon)[Yodaylay22](/maintainers/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

[ryangjchandler/blade-capture-directive

Create inline partials in your Blade templates with ease.

8222.2M12](/packages/ryangjchandler-blade-capture-directive)[leandrocfe/filament-ptbr-form-fields

Brazilian pt-BR form fields.

14398.7k](/packages/leandrocfe-filament-ptbr-form-fields)[spatie/laravel-blade-comments

Add debug comments to your rendered output

177325.5k](/packages/spatie-laravel-blade-comments)[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)
