BootstrapSiteAlertConfig.php in Bootstrap Site Alert 8.2
File
src/Form/BootstrapSiteAlertConfig.php
View source
<?php
namespace Drupal\bootstrap_site_alert\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class BootstrapSiteAlertConfig extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'bootstrap_site_alert.config',
];
}
public function getFormId() {
return 'bootstrap_site_alert_config';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('bootstrap_site_alert.config');
$form['bootstrap_site_alert_version'] = [
'#type' => 'select',
'#title' => $this
->t('Select Bootstrap Version'),
'#options' => [
'3' => $this
->t('3'),
'4' => $this
->t('4'),
'5' => $this
->t('5'),
],
'#empty_option' => $this
->t('- SELECT -'),
'#required' => TRUE,
'#default_value' => $config
->get('bootstrap_site_alert_version'),
];
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) {
$this
->config('bootstrap_site_alert.config')
->set('bootstrap_site_alert_version', $form_state
->getValue('bootstrap_site_alert_version')['value'])
->save();
parent::submitForm($form, $form_state);
}
}