You are here

public function SettingsForm::buildForm in Content Planner 8

Same name in this branch
  1. 8 modules/content_kanban/src/Form/SettingsForm.php \Drupal\content_kanban\Form\SettingsForm::buildForm()
  2. 8 modules/content_calendar/src/Form/SettingsForm.php \Drupal\content_calendar\Form\SettingsForm::buildForm()

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

modules/content_kanban/src/Form/SettingsForm.php, line 82

Class

SettingsForm
Defines a form that configures forms module settings.

Namespace

Drupal\content_kanban\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {

  // If the Content Calendar module is not enabled, set the use color setting
  // to inactive.
  if (!$this->kanbanService
    ->contentCalendarModuleIsEnabled()) {
    $this
      ->saveColorSetting(0);
  }
  $config = $this
    ->config(self::CONFIG_NAME);
  $form['advice'] = [
    '#title' => 'Disclaimer',
    '#type' => 'fieldset',
    '#weight' => 78,
    '#description' => $this
      ->t('Ensure all workflow state are set as a Default Revision in order to allow kanban table to work properly'),
  ];
  $form['options'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Options'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  ];

  // Content Calendar colors.
  $form['options']['use_content_calendar_colors'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use the defined colors from Content Calendar'),
    '#description' => $this
      ->t('This setting is only available if the Content Calendar is enabled and configured properly.'),
    '#default_value' => $config
      ->get('use_content_calendar_colors'),
    '#disabled' => !$this->kanbanService
      ->contentCalendarModuleIsEnabled(),
  ];

  // Show user thumb checkbox.
  $user_picture_field_exists = !$this
    ->config('field.field.user.user.user_picture')
    ->isNew();
  $form['options']['show_user_thumb'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show thumbnail image of User image'),
    '#description' => $this
      ->t('This option is only available, if the User account has the "user_picture" field. See Account configuration.'),
    '#disabled' => !$user_picture_field_exists,
    '#default_value' => $this->config
      ->get('show_user_thumb'),
  ];
  $default_date_range_value = self::DEFAULT_DATE_RANGE_VALUE;
  if ($this->config
    ->get('default_filter_date_range')) {
    $default_date_range_value = $this->config
      ->get('default_filter_date_range');
  }
  $form['options']['default_filter_date_range'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Date range'),
    '#options' => \Drupal\content_kanban\Form\KanbanFilterForm::getDateRangeOptions(),
    '#required' => FALSE,
    '#empty_value' => '',
    '#empty_option' => $this
      ->t('All'),
    '#default_value' => $default_date_range_value,
  ];
  return parent::buildForm($form, $form_state);
}