respondjs-8.x-1.x-dev/src/Form/RespondjsSettingForm.php
src/Form/RespondjsSettingForm.php
<?php
namespace Drupal\respondjs\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Form handler for configuring respondjs.
*/
class RespondjsSettingForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'respondjs_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'respondjs.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->configFactory->getEditable('respondjs.settings');
$form['warn'] = [
'#type' => 'checkbox',
'#title' => $this->t('Do not warn me about CSS aggregation.'),
'#description' => $this->t("Check this box if you'd rather not see the warning about CSS aggregation.<br> Disabling the warning will not make the respond.js function properly, but it will suppress the error message."),
'#default_value' => !empty($config->get('warn')) ? $config->get('warn') : FALSE,
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->configFactory->getEditable('respondjs.settings')
->set('warn', (bool) $form_state->getValue('warn'))
->save();
parent::submitForm($form, $form_state);
}
}
