RedhenAdminSettingsForm.php in RedHen CRM 8
File
src/Form/RedhenAdminSettingsForm.php
View source
<?php
namespace Drupal\redhen\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class RedhenAdminSettingsForm extends ConfigFormBase {
public function getFormID() {
return 'redhen_admin_settings';
}
protected function getEditableConfigNames() {
return [
'redhen.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('redhen.settings');
$form['redhen_admin_path'] = [
'#title' => $this
->t('Treat RedHen paths as administrative'),
'#type' => 'checkbox',
'#description' => $this
->t('This is used by other modules to, for example, use the admin theme on RedHen paths.'),
'#default_value' => $config
->get('redhen_admin_path'),
];
return parent::buildForm($form, $form_state);
}
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('redhen.settings');
$config
->set('redhen_admin_path', $form_state
->getValue('redhen_admin_path'))
->save();
parent::submitForm($form, $form_state);
}
}