You are here

public function CalendarSettingsForm::buildForm in Calendar 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/CalendarSettingsForm.php, line 32

Class

CalendarSettingsForm
Defines the admin configuration form for the calendar module.

Namespace

Drupal\calendar\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $calendar_config = $this
    ->config('calendar.settings');
  $form['calendar_settings'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Calendar Administration'),
    '#open' => TRUE,
  ];
  $form['calendar_settings']['track_date'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Track current date in session'),
    '#default_value' => $calendar_config
      ->get('track_date'),
    '#options' => [
      0 => $this
        ->t("Never"),
      1 => $this
        ->t('For authenticated users'),
      2 => $this
        ->t('For all users'),
    ],
    '#description' => $this
      ->t("Store session information about the user's current date as they move back and forth through the calendar. Without this setting users will revert to the current day each time they choose a new calendar period (year, month, week, or day). With this option set they will move to a day that conforms to the time period they were viewing before they switched. Requires session tracking which is not ordinarily enabled for anonymous users."),
  ];
  $form['calendar_settings']['add_colorbox'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Add Colorbox settings to Node calendar templates'),
    '#default_value' => $calendar_config
      ->get('add_colorbox'),
    '#options' => [
      0 => $this
        ->t('No'),
      1 => $this
        ->t('Yes'),
    ],
    '#description' => $this
      ->t('To try the Colorbox settings, choose the option to add Colorbox settings to the calendar templates. Install and enable the Colorbox module, following the instructions on the Colorbox project page, then create a new calendar from a template using any date field in the Node base table. The calendar will be set up to display the calendar items in a Colorbox.'),
  ];
  return $form;
}