I would like to add a submission handler to my form class so that the submitted values are saved. The parent class does not save them but only displays a message. I use Drupal 8! Here is my form class:
<?php namespace DrupalgreetingForm; use DrupalCoreFormConfigFormBase; use DrupalCoreFormFormStateInterface; class GreetingForm extends ConfigFormBase { /** * {@inheritdoc} */ public function getFormId() { return 'greeting_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('greeting.settings'); $form['page_text'] = array( '#type' => 'textarea', '#title' => $this->t('Content of the Greeting page'), '#default_value' => $config->get('page_text'), '#description' => $this->t('Allows you to define the text of the Greeting page'), ); return $form; } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config('greeting.settings'); $config->set('page_text', $form_state->getValue('page_text')); $config->save(); return parent::submitForm($form, $form_state); } /** * {@inheritdoc} */ protected function getEditableConfigNames() { return [ 'greeting.settings', ]; } } $config = Drupal::config('greeting.settings'); $page_title = $config->get('page_text');``` How do I do it? Thank you, Alexis Grolot