You are here

public function FarmSettingsFarmInfoForm::submitForm in farmOS 2.x

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/core/settings/src/Form/FarmSettingsFarmInfoForm.php, line 127

Class

FarmSettingsFarmInfoForm
Form for configuring basic farm info.

Namespace

Drupal\farm_settings\Form

Code

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

  // Get the submitted site name.
  $site_name = $form_state
    ->getvalue('site_name');

  // Update system.site config.
  $this->configFactory
    ->getEditable('system.site')
    ->set('name', $site_name)
    ->save();

  // Get the submitted country.
  $default_country = $form_state
    ->getValue('default_country');

  // Get the submitted timezone.
  $default_timezone = $form_state
    ->getValue('default_timezone');

  // Update system.date config.
  $this->configFactory
    ->getEditable('system.date')
    ->set('timezone.default', $default_timezone)
    ->set('country.default', $default_country)
    ->save();

  // Display message from parent submitForm.
  parent::submitForm($form, $form_state);
}