FasttoggleSettingsForm.php in Fasttoggle 8.3
File
src/Form/FasttoggleSettingsForm.php
View source
<?php
namespace Drupal\fasttoggle\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class FasttoggleSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'fasttoggle_settings';
}
protected function getEditableConfigNames() {
return [
'fasttoggle.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('fasttoggle.settings');
$form = [];
$form['label_style'] = [
'#type' => 'radios',
'#title' => $this
->t('Label style'),
'#description' => $this
->t('Select what kind of labels you want for fasttoggle links.'),
'#options' => [
0 => $this
->t('Status (reflects the current state, e.g. "published", "active")'),
1 => $this
->t('Action (shows what happens upon a click, e.g. "unpublish", "block")'),
],
'#default_value' => $config
->get('label_style'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$this
->config('fasttoggle.settings')
->set('label_style', $values['label_style'])
->save();
$this
->messenger()
->addMessage($this
->t('The configuration options have been saved.'));
}
}