CPF
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
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
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".
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.

