You are here

public function AddtocalView::settingsForm in Add to Cal 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/AddtocalView.php \Drupal\addtocal\Plugin\Field\FieldFormatter\AddtocalView::settingsForm()

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 DateTimeCustomFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/AddtocalView.php, line 103

Class

AddtocalView
Add to Cal view formatter.

Namespace

Drupal\addtocal\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $form = parent::settingsForm($form, $form_state);
  $field = $this->fieldDefinition;

  // Date Range field type settings.
  if ($field
    ->getType() == 'daterange' || $field
    ->getType() == 'date_recur') {
    $form['separator'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Date separator'),
      '#description' => $this
        ->t('The string to separate the start and end dates'),
      '#default_value' => $this
        ->getSetting('separator'),
    ];
  }
  $form['event_title'] = [
    '#title' => $this
      ->t('Event title'),
    '#type' => 'textfield',
    '#default_value' => $this
      ->getSetting('event_title'),
    '#description' => $this
      ->t('Optional - if left empty, the entity label will be used. You can use static text or tokens.'),
  ];
  $form['location'] = [
    '#title' => $this
      ->t('Event location'),
    '#type' => 'textarea',
    '#default_value' => $this
      ->getSetting('location'),
    '#description' => $this
      ->t('Optional. You can use static text or tokens.'),
  ];
  $form['description'] = [
    '#title' => $this
      ->t('Event description'),
    '#type' => 'textarea',
    '#default_value' => $this
      ->getSetting('description'),
    '#description' => $this
      ->t('Optional. You can use static text or tokens.'),
  ];
  $form['past_events'] = [
    '#title' => $this
      ->t('Show Add to Cal widget for past events?'),
    '#type' => 'checkbox',
    '#default_value' => $this
      ->getSetting('past_events'),
  ];
  $form['token_tree_link'] = [
    '#theme' => 'token_tree_link',
    '#token_types' => [
      $field
        ->getTargetEntityTypeId(),
    ],
  ];
  return $form;
}