SettingsForm.php in Synonyms 2.0.x
File
modules/synonyms_list_field/src/Form/SettingsForm.php
View source
<?php
namespace Drupal\synonyms_list_field\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class SettingsForm extends ConfigFormBase {
use StringTranslationTrait;
public function getFormId() {
return 'synonyms_list_field_settings';
}
protected function getEditableConfigNames() {
return [
'synonyms_list_field.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['include_entity_label'] = [
'#type' => 'checkbox',
'#title' => t('Include entity label'),
'#default_value' => $this
->config('synonyms_list_field.settings')
->get('include_entity_label'),
'#description' => $this
->t('If checked, the entity label is prepended to computed "Synonyms list" field.'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('synonyms_list_field.settings')
->set('include_entity_label', $form_state
->getValue('include_entity_label'))
->save();
parent::submitForm($form, $form_state);
}
}