SettingsForm.php in Gin Layout Builder 1.0.x
File
src/Form/SettingsForm.php
View source
<?php
namespace Drupal\gin_lb\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class SettingsForm extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'gin_lb.settings',
];
}
public function getFormId() {
return 'gin_lb_settings_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('gin_lb.settings');
$form['toastify_cdn'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Load Toastify From CDN'),
'#description' => $this
->t('If you uncheck this box, you will have load Toastify yourself in your theme.'),
'#default_value' => $config
->get('toastify_cdn'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('gin_lb.settings')
->set('toastify_cdn', $form_state
->getValue('toastify_cdn'))
->save();
}
}