LBATConfigForm.php in Layout builder admin theme 8
File
src/Form/LBATConfigForm.php
View source
<?php
namespace Drupal\layout_builder_admin_theme\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class LBATConfigForm extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'layout_builder_admin_theme.config',
];
}
public function getFormId() {
return 'lbat_config_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('layout_builder_admin_theme.config');
$form['lbat_enable_admin_theme'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable admin theme for layout builder'),
'#default_value' => $config
->get('lbat_enable_admin_theme'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('layout_builder_admin_theme.config')
->set('lbat_enable_admin_theme', $form_state
->getValue('lbat_enable_admin_theme'))
->save();
}
}