You are here

public function SmartDateFormatSettingsForm::submitForm in Smart Date 8

Same name and namespace in other branches
  1. 8.2 src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::submitForm()
  2. 3.x src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::submitForm()
  3. 3.0.x src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::submitForm()
  4. 3.1.x src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::submitForm()
  5. 3.2.x src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::submitForm()
  6. 3.3.x src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::submitForm()
  7. 3.4.x src/Form/SmartDateFormatSettingsForm.php \Drupal\smart_date\Form\SmartDateFormatSettingsForm::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 FormInterface::submitForm

File

src/Form/SmartDateFormatSettingsForm.php, line 33

Class

SmartDateFormatSettingsForm
Class SmartDateSettingsForm.

Namespace

Drupal\smart_date\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = \Drupal::service('config.factory')
    ->getEditable('smart_date_settings.settings');
  foreach ($form_state
    ->getValues() as $key => $value) {
    if (strpos($key, 'smart_date_format_') !== FALSE) {
      $config
        ->set(str_replace('smart_date_format_', '', $key), $value);
    }
  }
  $config
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Configuration was saved.'));
}