You are here

public function SettingsForm::submitForm in CRM Core 8.3

Same name in this branch
  1. 8.3 src/Form/SettingsForm.php \Drupal\crm_core\Form\SettingsForm::submitForm()
  2. 8.3 modules/crm_core_user_sync/src/Form/SettingsForm.php \Drupal\crm_core_user_sync\Form\SettingsForm::submitForm()
Same name and namespace in other branches
  1. 8 modules/crm_core_user_sync/src/Form/SettingsForm.php \Drupal\crm_core_user_sync\Form\SettingsForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

modules/crm_core_user_sync/src/Form/SettingsForm.php, line 172

Class

SettingsForm
Configure crm_core_user_sync settings.

Namespace

Drupal\crm_core_user_sync\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('crm_core_user_sync.settings');
  $rules = $config
    ->get('rules');
  $rule_values = $form_state
    ->getValue('rules', []);
  if (!empty($rule_values)) {
    foreach ($rule_values as $key => $values) {
      if (!empty($values['weight'])) {
        $rules[$key]['weight'] = $values['weight'];
      }
    }
  }
  uasort($rules, [
    $this,
    'weightCmp',
  ]);
  $config
    ->set('rules', $rules)
    ->set('auto_sync_user_create', $form_state
    ->getValue('auto_sync_user_create'))
    ->set('auto_sync_user_relate', $form_state
    ->getValue('auto_sync_user_relate'))
    ->set('contact_load', $form_state
    ->getValue('contact_load'))
    ->set('contact_show', $form_state
    ->getValue('contact_show'))
    ->save();
  parent::submitForm($form, $form_state);
}