CourseSettingsForm.php in Course 8.2
File
src/Form/CourseSettingsForm.php
View source
<?php
namespace Drupal\course\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class CourseSettingsForm extends ConfigFormBase {
protected function getEditableConfigNames() : array {
return [
'course.settings',
];
}
public function getFormId() : string {
return 'course_settings_overview';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('course.settings');
$form['testing'] = [
'#type' => 'textarea',
'#title' => $this
->t('Welcome message'),
'#description' => $this
->t('Welcome message display to users when they login'),
'#default_value' => $config
->get('testing'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('course.settings')
->setData($form_state
->getValues())
->save();
parent::submitForm($form, $form_state);
}
}