You are here

public function TimezoneDetectSettings::buildForm in Timezone Detect 8

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/TimezoneDetectSettings.php, line 45
Administration pages for Timezone Detect module.

Class

TimezoneDetectSettings
Administration form.

Namespace

Drupal\timezone_detect\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('timezone_detect.settings');
  $options = [
    TimezoneDetectInterface::MODE_DEFAULT => $this
      ->t("Set timezone on login only if it is not yet set (recommended)"),
    TimezoneDetectInterface::MODE_LOGIN => $this
      ->t("Update timezone on every login"),
    TimezoneDetectInterface::MODE_ALWAYS => $this
      ->t("Update timezone whenever it changes"),
  ];
  $form['mode'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t("When to set a user's timezone automatically"),
    '#default_value' => $config
      ->get('mode'),
    '#options' => $options,
    '#description' => $this
      ->t("By default, Timezone Detect sets a user's timezone on login if it is not yet set. Alternatively, you can have the module update the user's timezone automatically on every login or whenever their timezone changes; be aware that these later settings will overwrite any manual timezone selection that the user may make."),
  ];
  $form['watchdog'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t("Log successful events in watchdog"),
    '#default_value' => $config
      ->get('watchdog'),
    '#description' => $this
      ->t("By default, Timezone Detect will create a log entry every time it sets a user's timezone. This can create unnecessary noise in your log files so you are likely to want to disable this once you are confident the feature works."),
  ];
  return parent::buildForm($form, $form_state);
}