3 namespace Drupal\system\Form;
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Form to select the administration theme.
11 class ThemeAdminForm extends ConfigFormBase {
16 public function getFormId() {
17 return 'system_themes_admin_form';
23 protected function getEditableConfigNames() {
24 return ['system.theme'];
30 public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) {
31 // Administration theme settings.
32 $form['admin_theme'] = [
34 '#title' => $this->t('Administration theme'),
37 $form['admin_theme']['admin_theme'] = [
39 '#options' => [0 => $this->t('Default theme')] + $theme_options,
40 '#title' => $this->t('Administration theme'),
41 '#description' => $this->t('Choose "Default theme" to always use the same theme as the rest of the site.'),
42 '#default_value' => $this->config('system.theme')->get('admin'),
44 $form['admin_theme']['actions'] = ['#type' => 'actions'];
45 $form['admin_theme']['actions']['submit'] = [
47 '#value' => $this->t('Save configuration'),
48 '#button_type' => 'primary',
56 public function submitForm(array &$form, FormStateInterface $form_state) {
57 parent::submitForm($form, $form_state);
58 $this->config('system.theme')->set('admin', $form_state->getValue('admin_theme'))->save();