Note: CPF (Cadastro de Pessoas Físicas, in portuguese) is the Brazilian individual taxpayer registry identification granted to individuals by the Brazilian ministry of revenue. Learn more about it at wikipedia.
This module basically provides two features:
- a CPF field type
- a CPF form element
I. CPF Field Type
A simple field for storing CPF number data in Drupal 8.
Validations
The module provides 3 types of validation:
- If the CPF number is valid.
- If unique values, in multiple fields, were entered.
- If unique values for the same entity were entered (optional).
Widgets and Formatters
It adds 2 new widgets to the text field type at the Field UI. They are:
Mask - A textfield with a mask in the format 000.000.000-00
Digits - A textfield with a mask in the format 00000000000
The view format display are done as followed:
Masked - 000.000.000-00
Only Digits - 00000000000
Developers
In the settings of the two widgets there is the option "Enable link to generate CPF numbers". If enabled, a link will be added under the field widget, allowing you to generate a valid CPF number for testing use.
Note: to view the link the user must have the permission "Access the CPF number generator".
II. CPF Form Element
It also provides a new form input element for entering a CPF number. So, developers can easily build form elements of CPF number. For example:
$form['cpf'] = array(
'#type' => 'cpf',
'#title' => t('CPF number'),
'#mask' => FALSE,
);
If the #mask key is set to FALSE the field will only allow entred of digits. Otherwise, a canonical mask will be applied, that is, 000.000.000-00.
Note: this form element already has a routine that checks if the number entered is valid.
Developed and maintained by MMDA.
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.- Project categories: Site structure
497 sites report using this module
- Created by docapilar on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.





