You are here

public function ComputedCacheFormatterTrait::settingsForm in Computed Field 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/Field/FieldFormatter/ComputedCacheFormatterTrait.php \Drupal\computed_field\Plugin\Field\FieldFormatter\ComputedCacheFormatterTrait::settingsForm()
1 call to ComputedCacheFormatterTrait::settingsForm()
ComputedStringFormatter::settingsForm in src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php
1 method overrides ComputedCacheFormatterTrait::settingsForm()
ComputedStringFormatter::settingsForm in src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php

File

src/Plugin/Field/FieldFormatter/ComputedCacheFormatterTrait.php, line 63

Class

ComputedCacheFormatterTrait
Base formatter trait for computed fields.

Namespace

Drupal\computed_field\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return [
    'cache_unit' => [
      '#title' => t('Cache'),
      '#type' => 'select',
      '#default_value' => $this
        ->getSetting('cache_unit'),
      '#options' => $this
        ->unitOptions('plural'),
      '#description' => t('Here you can change the caching of the formatted value: "default" means until it is saved again, "off" no caching, others are units to cache the value according to the duration entered below. If you select a value different from "default", the formatted value will be recomputed as necessary, <b>but he saved value will not be changed</b>, so the displayed value may be different from the saved value!</br><b>You should not change the default unless the computed value consists of volatile components like current time/date/user!</b>'),
      '#weight' => 99,
    ],
    'cache_duration' => [
      '#title' => t('Cache duration'),
      '#type' => 'number',
      '#min' => 1,
      '#default_value' => $this
        ->getSetting('cache_duration'),
      '#description' => t('This value is valid only when you select a unit above'),
      '#weight' => 99,
    ],
  ] + parent::settingsForm($form, $form_state);
}