FormsStepsSettingsForm.php in Forms Steps 8
File
src/Form/FormsStepsSettingsForm.php
View source
<?php
namespace Drupal\forms_steps\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class FormsStepsSettingsForm extends ConfigFormBase {
protected $config = 'forms_steps.settings';
protected function getEditableConfigNames() {
return [
'forms_steps.settings',
];
}
public function getFormId() {
return 'forms_steps_settings_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config($this->config);
$form['message'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message'),
'#description' => $this
->t('Message description'),
'#defaut_value' => $config
->get('message'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config($this->config)
->set('message', $form_state
->getValue('message'))
->save();
}
}