class MapboxSettingsForm in farmOS 2.x
Provides a mapbox settings form.
Hierarchy
- class \Drupal\farm_map_mapbox\Form\MapboxSettingsForm extends \Drupal\farm_map_mapbox\Form\ConfigFormbase
Expanded class hierarchy of MapboxSettingsForm
1 string reference to 'MapboxSettingsForm'
- farm_map_mapbox.routing.yml in modules/
core/ map/ modules/ mapbox/ farm_map_mapbox.routing.yml - modules/core/map/modules/mapbox/farm_map_mapbox.routing.yml
File
- modules/
core/ map/ modules/ mapbox/ src/ Form/ MapboxSettingsForm.php, line 11
Namespace
Drupal\farm_map_mapbox\FormView source
class MapboxSettingsForm extends ConfigFormbase {
/**
* Config settings.
*
* @var string
*/
const SETTINGS = 'farm_map_mapbox.settings';
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'farm_map_mapbox_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
static::SETTINGS,
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateinterface $form_state) {
$config = $this
->config(static::SETTINGS);
// Add api_key field.
$form['api_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('Mapbox API Key'),
'#description' => $this
->t('Enter your Mapbox API key.'),
'#default_value' => $config
->get('api_key'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->configFactory
->getEditable(static::SETTINGS)
->set('api_key', $form_state
->getValue('api_key'))
->save();
parent::submitForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MapboxSettingsForm:: |
public | function | ||
MapboxSettingsForm:: |
protected | function | ||
MapboxSettingsForm:: |
public | function | ||
MapboxSettingsForm:: |
constant | Config settings. | ||
MapboxSettingsForm:: |
public | function |