class RoutePlannerSettingsForm in Route Planner 8
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\route_planner\Form\RoutePlannerSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of RoutePlannerSettingsForm
1 string reference to 'RoutePlannerSettingsForm'
File
- src/
Form/ RoutePlannerSettingsForm.php, line 9
Namespace
Drupal\route_planner\FormView source
class RoutePlannerSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}.
*/
public function getEditableConfigNames() {
return [
'route_planner.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'route_planner_settings_form';
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->getEditable('route_planner.settings');
foreach (Element::children($form) as $fieldset) {
foreach (Element::children($form[$fieldset]) as $variable) {
$config
->set($variable, $form_state
->getValue($variable));
}
}
$config
->save();
parent::submitForm($form, $form_state);
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['route_planner'] = array(
'#type' => 'fieldset',
'#title' => $this
->t('Route Planner Settings'),
);
$form['route_planner']['route_planner_address'] = array(
'#type' => 'textfield',
'#description' => $this
->t('Your point of interesst or company address.'),
'#title' => $this
->t('Target address'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_address'),
);
$form['route_planner']['route_planner_address_end'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Show an end point field.'),
'#description' => $this
->t('If checked the address block will have a end point field with the default address from your POI above.'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_address_end'),
);
$form['route_planner']['route_planner_unitsystem'] = array(
'#type' => 'select',
'#description' => $this
->t('Select your preferred unit system IMPERIAL or METRIC.'),
'#title' => $this
->t('Unit System'),
'#options' => array(
0 => t('metric'),
1 => t('imperial'),
),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_unitsystem'),
);
// API settings
$form['api-settings'] = array(
'#type' => 'fieldset',
'#title' => $this
->t('Google Maps JavaScript API Settings'),
);
$form['api-settings']['route_planner_api_key'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Google Maps JavaScript API Key'),
'#description' => $this
->t('Visit <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">developers.google.com > Get Key</a> for details on how to get a key.'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_api_key'),
);
$form['api-settings']['route_planner_api_language'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Language Localization'),
'#description' => $this
->t('Visit <a href="https://developers.google.com/maps/documentation/javascript/localization">developers.google.com > Maps Localization</a> for details.'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_api_language'),
);
$form['map-settings'] = array(
'#type' => 'fieldset',
'#title' => $this
->t('Map Settings'),
);
$form['map-settings']['route_planner_map_height'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Map Height'),
'#description' => $this
->t('A fixed height for example 300px.'),
'#size' => 10,
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_height'),
);
$form['map-settings']['route_planner_map_width'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Map Width'),
'#description' => $this
->t('A width value in % or px, for example 300px or 100%.'),
'#size' => 10,
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_width'),
);
$form['map-settings']['route_planner_map_zoom'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Zoom Level'),
'#description' => $this
->t('A value between 1 and 100 (a normal value is around 10).'),
'#size' => 10,
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_zoom'),
);
$form['map-settings']['route_planner_map_defaultui'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Disable Default UI Controls'),
'#description' => $this
->t('Disables all UI Controls in the map.'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_defaultui'),
);
$form['map-settings']['route_planner_map_zoomcontrol'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable ZoomControl'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_zoomcontrol'),
);
$form['map-settings']['route_planner_map_scrollwheel'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable ScrollWheel'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_scrollwheel'),
);
$form['map-settings']['route_planner_map_maptypecontrol'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable Map Type Control'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_maptypecontrol'),
);
$form['map-settings']['route_planner_map_scalecontrol'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable Scale Control'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_scalecontrol'),
);
$form['map-settings']['route_planner_map_draggable'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable Mouse Drag'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_draggable'),
);
$form['map-settings']['route_planner_map_doubbleclick'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Disable Doubble Click Zoom'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_doubbleclick'),
);
$form['map-settings']['route_planner_map_streetviewcontrol'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable Streetview Control'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_streetviewcontrol'),
);
$form['map-settings']['route_planner_map_overviewmapcontrol'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enable Overview Map'),
'#default_value' => \Drupal::config('route_planner.settings')
->get('route_planner_map_overviewmapcontrol'),
);
return parent::buildForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
RoutePlannerSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
RoutePlannerSettingsForm:: |
public | function |
. Overrides ConfigFormBaseTrait:: |
|
RoutePlannerSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
RoutePlannerSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |