function TextTrimmedFormatter::settingsForm

Same name and namespace in other branches
  1. 9 core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::settingsForm()
  2. 10 core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::settingsForm()
  3. 11.x 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 45

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' => t('Trimmed limit'),
        '#type' => 'number',
        '#field_suffix' => t('characters'),
        '#default_value' => $this->getSetting('trim_length'),
        '#description' => 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.