public function GeolocationSettings::buildForm in GeoIP API 8.2
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ GeolocationSettings.php, line 30
Class
- GeolocationSettings
- Settings form to configure GeoIP.
Namespace
Drupal\geoip\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('geoip.geolocation');
$form['plugin_id'] = [
'#type' => 'tableselect',
'#multiple' => FALSE,
'#header' => [
'label' => $this
->t('Label'),
'description' => $this
->t('Description'),
],
'#options' => [],
'#default_value' => $config
->get('plugin_id'),
];
foreach (\Drupal::service('plugin.manager.geolocator')
->getDefinitions() as $plugin_id => $definition) {
$form['plugin_id']['#options'][$plugin_id] = [
'label' => $definition['label'],
'description' => $definition['description'],
];
}
$form['debug'] = [
'#type' => 'radios',
'#title' => $this
->t('Enable debugging logs'),
'#options' => [
$this
->t('No'),
$this
->t('Yes'),
],
'#default_value' => (int) $config
->get('debug'),
];
return parent::buildForm($form, $form_state);
}