MapSettingsForm.php in farmOS 2.x
File
modules/core/map/src/Form/MapSettingsForm.php
View source
<?php
namespace Drupal\farm_map\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class MapSettingsForm extends ConfigFormbase {
const SETTINGS = 'farm_map.settings';
public function getFormId() {
return 'farm_map_settings';
}
protected function getEditableConfigNames() {
return [
static::SETTINGS,
];
}
public function buildForm(array $form, FormStateinterface $form_state) {
$config = $this
->config(static::SETTINGS);
$form['enable_side_panel'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable Side Panel'),
'#description' => $this
->t('Enable the side panel in farmOS maps for displaying additional settings and information.'),
'#default_value' => $config
->get('enable_side_panel'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->configFactory
->getEditable(static::SETTINGS)
->set('enable_side_panel', $form_state
->getValue('enable_side_panel'))
->save();
parent::submitForm($form, $form_state);
}
}