You are here

function brazilianids_settings_submit in Brazilian IDs 6

Implementation of hook_settings_submit().

1 string reference to 'brazilianids_settings_submit'
_brazilianids_admin in ./brazilianids.module
Module settings. Let users should which fields are needed

File

./brazilianids.module, line 205

Code

function brazilianids_settings_submit($form, &$form_state) {
  foreach ($form_state['values'] as $key => $form_value) {
    if ($key != 'brazilianids_registration' and $key != 'brazilianids_required') {
      eval('$' . $key . '=$form_value;');
    }
  }
  if ($brazilianids_enable_cpf == TRUE and $brazilianids_enable_cnpj == TRUE and $brazilianids_enable_cpfcnpj == TRUE) {
    variable_set('brazilianids_cpfcnpj', TRUE);
    $form_state['values']['brazilianids_enable_cpfcnpj'] = TRUE;
    variable_set('brazilianids_cpf', FALSE);
    $form_state['values']['brazilianids_enable_cpf'] = TRUE;
    variable_set('brazilianids_cnpj', FALSE);
    $form_state['values']['brazilianids_enable_cnpj'] = TRUE;
  }
  else {
    variable_set('brazilianids_cpf', $brazilianids_enable_cpf);
    $form_state['values']['brazilianids_enable_cpf'] = $brazilianids_enable_cpf;
    variable_set('brazilianids_cnpj', $brazilianids_enable_cnpj);
    $form_state['values']['brazilianids_enable_cnpj'] = $brazilianids_enable_cnpj;
    variable_set('brazilianids_cpfcnpj', FALSE);
    $form_state['values']['brazilianids_enable_cpfcnpj'] = FALSE;
    if ($brazilianids_enable_cpf != $brazilianids_enable_cnpj and $brazilianids_enable_cpfcnpj == TRUE) {
      drupal_set_message(t('"Use the same field for CPF or CNPJ" was disabled because you enabled only one that fields, CPF or CNPJ.'), 'warning');
    }
  }
}