CourseAppearanceSettingsForm.php in Course 3.x
File
src/Form/CourseAppearanceSettingsForm.php
View source
<?php
namespace Drupal\course\Form;
use Drupal;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class CourseAppearanceSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'course_appearance_settings_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('course.settings.appearance');
$form['take_tab_display'] = array(
'#title' => t('Show a "take course" tab on course nodes'),
'#type' => 'checkbox',
'#default_value' => $config
->get('take_tab_display'),
);
$theme = \Drupal::service('theme_handler')
->getDefault();
$form['disable_regions'] = array(
'#title' => t('Disable theme regions when taking a course'),
'#type' => 'checkboxes',
'#default_value' => $config
->get('disable_regions'),
'#options' => system_region_list($theme),
);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('course.settings.appearance')
->setData($form_state
->getValues())
->save();
parent::submitForm($form, $form_state);
}
protected function getEditableConfigNames() : array {
return [
'course.settings.appearance',
];
}
}