SettingsForm.php in Simple Meta 8.2
File
src/Form/SettingsForm.php
View source
<?php
namespace Drupal\simplemeta\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class SettingsForm extends ConfigFormBase {
public function getFormId() {
return 'simplemeta_settings';
}
protected function getEditableConfigNames() {
return [
'simplemeta.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('simplemeta.settings');
$form['form_enable'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable Add Meta Tags Form'),
'#description' => $this
->t('If enabled, form will appear on pages'),
'#default_value' => $config
->get('form_enable'),
'#return_value' => TRUE,
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('simplemeta.settings');
$config
->set('form_enable', $form_state
->getValue('form_enable'))
->save();
parent::submitForm($form, $form_state);
}
}