cloud-8.x-2.0-beta1/src/Form/Config/CloudAdminSettings.php
src/Form/Config/CloudAdminSettings.php
<?php
namespace Drupal\cloud\Form\Config;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class Cloud Admin Settings.
*/
class CloudAdminSettings extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'cloud_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return ['cloud.settings'];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('cloud.settings');
$form['location_map'] = [
'#type' => 'details',
'#title' => $this->t('Location Map'),
'#open' => TRUE,
];
$form['location_map']['cloud_location_map_json_url'] = [
'#type' => 'url',
'#title' => $this->t('Location Map JSON URL'),
'#default_value' => $config->get('cloud_location_map_json_url'),
'#description' => $this->t('The URL of the geojson file to draw the location map.'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory()->getEditable('cloud.settings');
$config->set('cloud_location_map_json_url', $form_state->getValue('cloud_location_map_json_url'));
$config->save();
parent::submitForm($form, $form_state);
}
}
