You are here

public function GeocodioSettings::submitForm in Geolocation Field 8.3

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/geolocation_geocodio/src/Form/GeocodioSettings.php, line 57

Class

GeocodioSettings
Implements the Geocodio form controller.

Namespace

Drupal\geolocation_geocodio\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->configFactory()
    ->getEditable('geolocation_geocodio.settings');
  $config
    ->set('api_key', $form_state
    ->getValue('api_key'));
  $config
    ->set('fields', $form_state
    ->getValue('fields'));
  $config
    ->save();

  // Confirmation on form submission.
  \Drupal::messenger()
    ->addMessage($this
    ->t('The configuration options have been saved.'));
  drupal_flush_all_caches();
}