You are here

public function TimeFieldMiniCalendar::settingsForm in Timefield 1.0.x

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/TimeFieldMiniCalendar.php, line 51

Class

TimeFieldMiniCalendar
Plugin for the 'timefield_mini_calendar_formatter' field formatter.

Namespace

Drupal\timefield\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  // @todo Change the autogenerated stub
  $element = parent::settingsForm($form, $form_state);
  $settings = $this
    ->getSettings();
  $element += _timefield_display_format_form('column_format', "Column Time Settings", $settings);
  $element['first_day'] = [
    '#title' => $this
      ->t('First Day of the Week'),
    '#type' => 'select',
    '#options' => _timefield_weekly_summary_days(),
    '#default_value' => $settings['first_day'],
    '#required' => TRUE,
  ];
  $element['absolute_start'] = [
    '#title' => $this
      ->t('Mini Cal Start Time'),
    '#description' => $this
      ->t('The Start Time of the Calendar'),
    '#type' => 'textfield',
    '#default_value' => $settings['absolute_start'],
    '#size' => 15,
    '#maxlength' => 15,
    '#attributes' => [
      'class' => [
        'edit-timefield-timepicker',
        $instance_class,
      ],
    ],
  ];
  $element['absolute_end'] = [
    '#title' => $this
      ->t('Mini Cal End Time'),
    '#description' => $this
      ->t('The End Time of the Calendar'),
    '#type' => 'textfield',
    '#default_value' => $settings['absolute_end'],
    '#size' => 15,
    '#maxlength' => 15,
    '#attributes' => [
      'class' => [
        'edit-timefield-timepicker',
        $instance_class,
      ],
    ],
  ];
  $element['range'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select the time duration of each block of time'),
    '#options' => [
      30 => $this
        ->t('30 Minutes'),
      60 => $this
        ->t('1 Hour'),
      90 => $this
        ->t('90 minutes'),
      120 => $this
        ->t('2 Hours'),
      180 => $this
        ->t('3 Hours'),
      240 => $this
        ->t('4 Hours'),
    ],
    '#default_value' => $settings['range'],
  ];
  $element['adjust_range'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Adjust Range to fit Items'),
    '#default_value' => $settings['adjust_time'],
  ];
  $element += _timefield_display_format_form('display_format', "Individual Time Display Settings", $settings);
  return $element;
}