'textfield', '#title' => $this->t('Example'), '#default_value' => $this->config('{{ machine_name }}.settings')->get('example'), ]; return parent::buildForm($form, $form_state); } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { if ($form_state->getValue('example') != 'example') { $form_state->setErrorByName('example', $this->t('The value is not correct.')); } parent::validateForm($form, $form_state); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('{{ machine_name }}.settings') ->set('example', $form_state->getValue('example')) ->save(); parent::submitForm($form, $form_state); } }