3 namespace Drupal\system\Form;
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Form to select the administration theme.
13 class ThemeAdminForm extends ConfigFormBase {
18 public function getFormId() {
19 return 'system_themes_admin_form';
25 protected function getEditableConfigNames() {
26 return ['system.theme'];
32 public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) {
33 // Administration theme settings.
34 $form['admin_theme'] = [
36 '#title' => $this->t('Administration theme'),
39 $form['admin_theme']['admin_theme'] = [
41 '#options' => [0 => $this->t('Default theme')] + $theme_options,
42 '#title' => $this->t('Administration theme'),
43 '#description' => $this->t('Choose "Default theme" to always use the same theme as the rest of the site.'),
44 '#default_value' => $this->config('system.theme')->get('admin'),
46 $form['admin_theme']['actions'] = ['#type' => 'actions'];
47 $form['admin_theme']['actions']['submit'] = [
49 '#value' => $this->t('Save configuration'),
50 '#button_type' => 'primary',
58 public function submitForm(array &$form, FormStateInterface $form_state) {
59 parent::submitForm($form, $form_state);
60 $this->config('system.theme')->set('admin', $form_state->getValue('admin_theme'))->save();