function TextTrimmedFormatter::settingsForm

Same name in other branches
  1. 9 core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::settingsForm()
  2. 8.9.x core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::settingsForm()
  3. 10 core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::settingsForm()

Overrides FormatterBase::settingsForm

File

core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php, line 43

Class

TextTrimmedFormatter
Plugin implementation of the 'text_trimmed' formatter.

Namespace

Drupal\text\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
    $element['trim_length'] = [
        '#title' => $this->t('Trimmed limit'),
        '#type' => 'number',
        '#field_suffix' => $this->t('characters'),
        '#default_value' => $this->getSetting('trim_length'),
        '#description' => $this->t('If the summary is not set, the trimmed %label field will end at the last full sentence before this character limit.', [
            '%label' => $this->fieldDefinition
                ->getLabel(),
        ]),
        '#min' => 1,
        '#required' => TRUE,
    ];
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.