You are here

public function ContactSettingsForm::submitForm in RedHen CRM 8

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/redhen_contact/src/Form/ContactSettingsForm.php, line 42

Class

ContactSettingsForm
Class ContactSettingsForm.

Namespace

Drupal\redhen_contact\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Must require a valid email to connect Contacts and Drupal Users.
  $connect_users = $form_state
    ->getValue('valid_email') && $form_state
    ->getValue('connect_users');

  // Contacts must be connected to Users if we're going to embed the Contact
  // fields on the User form.
  $embed_on_user_form = $form_state
    ->getValue('connect_users') && $form_state
    ->getValue('embed_on_user_form');

  // Require unique email if we're connecting Contacts to Users.
  $unique_email = $connect_users || $form_state
    ->getValue('unique_email');
  \Drupal::service('config.factory')
    ->getEditable('redhen_contact.settings')
    ->set('valid_email', $form_state
    ->getValue('valid_email'))
    ->set('required_properties', $form_state
    ->getValue('required_properties'))
    ->set('connect_users', $connect_users)
    ->set('embed_on_user_form', $embed_on_user_form)
    ->set('contact_user_form', $form_state
    ->getValue('contact_user_form'))
    ->set('unique_email', $unique_email)
    ->set('alter_username', $form_state
    ->getValue('alter_username'))
    ->set('registration', $form_state
    ->getValue('registration'))
    ->set('registration_type', $form_state
    ->getValue('registration_type'))
    ->set('registration_link', $form_state
    ->getValue('registration_link'))
    ->set('registration_form', $form_state
    ->getValue('registration_form'))
    ->set('registration_update', $form_state
    ->getValue('registration_update'))
    ->save();
  parent::submitForm($form, $form_state);
}