You are here

function br_tax_number_fields_form_alter in Brazilian IDs 7

Implements hook_form_alter().

Hide the unnecessary fields from settings page

File

./br_tax_number_fields.module, line 79
Adds Brazilian Tax Number field widgets to text field type at the Field UI and creates new form element types for use in the Form API.

Code

function br_tax_number_fields_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'field_ui_field_edit_form') {
    if (in_array($form['#instance']['widget']['type'], array(
      'number_cnpj',
      'number_cpf',
      'number_cnpj_cpf',
    ))) {
      $form['instance']['settings']['text_processing']['#type'] = 'hidden';
      $form['field']['settings']['max_length']['#type'] = 'hidden';
    }
  }
}