You are here

public function RngContactSettingsForm::submitForm in RNG Contact 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

src/Form/RngContactSettingsForm.php, line 120

Class

RngContactSettingsForm
Configure RNG Contact settings.

Namespace

Drupal\rng_contact\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($form_state
    ->getValue('table') as $contact_type_id => $row) {

    /** @var \Drupal\rng_contact\Entity\RngContactTypeInterface $contact_type */
    $contact_type = RngContactType::load($contact_type_id);
    $email_field = !empty($row['email_field']) ? $row['email_field'] : NULL;
    $contact_type
      ->setCourierEmailField($email_field);
    $contact_type
      ->save();
  }
  drupal_set_message($this
    ->t('Settings updated.'));
}