PdbNg2Form.php in Decoupled Blocks 8
File
modules/pdb_ng2/src/Form/PdbNg2Form.php
View source
<?php
namespace Drupal\pdb_ng2\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class PdbNg2Form extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'pdb_ng2.settings',
];
}
public function getFormId() {
return 'pdb_ng2_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('pdb_ng2.settings');
$form['development_mode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Development Mode'),
'#description' => $this
->t('Checking the box enables development mode'),
'#default_value' => $config
->get('development_mode'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$development_mode = $form_state
->getValue('development_mode');
$config = \Drupal::service('config.factory')
->getEditable('pdb_ng2.settings');
$config
->set('development_mode', $development_mode);
$config
->save();
}
}