You are here

public function SettingsForm::submitForm in Weather 8

Same name and namespace in other branches
  1. 2.0.x src/Form/SettingsForm.php \Drupal\weather\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

src/Form/SettingsForm.php, line 201

Class

SettingsForm
Configure Weather settings for this site.

Namespace

Drupal\weather\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $triggeredBy = $form_state
    ->getTriggeringElement();
  if ($triggeredBy && $triggeredBy['#id'] == 'edit-import-places-submit') {
    $this->weatherDataService
      ->weatherDataInstallation();
  }
  else {
    $this
      ->config('weather.settings')
      ->set('weather_image_directory', $form_state
      ->getValue('weather_image_directory'))
      ->set('weather_forecast_days', $form_state
      ->getValue('weather_forecast_days'))
      ->save();
    parent::submitForm($form, $form_state);
  }
}