You are here

public function SinglePageSiteConfigForm::submitForm in Single Page Site 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/SinglePageSiteConfigForm.php \Drupal\single_page_site\Form\SinglePageSiteConfigForm::submitForm()
  2. 2.x src/Form/SinglePageSiteConfigForm.php \Drupal\single_page_site\Form\SinglePageSiteConfigForm::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/SinglePageSiteConfigForm.php, line 218

Class

SinglePageSiteConfigForm
Class SinglePageSiteConfigForm.

Namespace

Drupal\single_page_site\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->config('single_page_site.config')
    ->set('menu', $form_state
    ->getValue('menu'))
    ->set('menuclass', $form_state
    ->getValue('menuclass'))
    ->set('class', $form_state
    ->getValue('class'))
    ->set('title', $form_state
    ->getValue('title'))
    ->set('tag', $form_state
    ->getValue('tag'))
    ->set('homepage', $form_state
    ->getValue('homepage'))
    ->set('down', $form_state
    ->getValue('scroll-down'))
    ->set('up', $form_state
    ->getValue('scroll-up'))
    ->set('smoothscrolling', $form_state
    ->getValue('smooth-scrolling'))
    ->set('updatehash', $form_state
    ->getValue('update-hash'))
    ->set('offsetselector', $form_state
    ->getValue('offset-selector'))
    ->set('filterurlprefix', $form_state
    ->getValue('filter-url-prefix'))
    ->save();
  if ($form_state
    ->getValue('homepage')) {

    // Set single-page-site as homepage.
    $this
      ->config('system.site')
      ->set('page.front', '/single-page-site')
      ->save();
  }
  $this
    ->messenger()
    ->addMessage(t('Your settings have been saved.'));
}