You are here

public function ParagraphsTrimmedFormatterBase::settingsForm in Paragraphs Trimmed 8

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

1 call to ParagraphsTrimmedFormatterBase::settingsForm()
ParagraphsSmartTrimFormatter::settingsForm in modules/paragraphs_smart_trim/src/Plugin/Field/FieldFormatter/ParagraphsSmartTrimFormatter.php
Returns a form to configure settings for the formatter.
1 method overrides ParagraphsTrimmedFormatterBase::settingsForm()
ParagraphsSmartTrimFormatter::settingsForm in modules/paragraphs_smart_trim/src/Plugin/Field/FieldFormatter/ParagraphsSmartTrimFormatter.php
Returns a form to configure settings for the formatter.

File

src/Plugin/Field/FieldFormatter/ParagraphsTrimmedFormatterBase.php, line 107

Class

ParagraphsTrimmedFormatterBase
Base class for paragraph trimmed formatters.

Namespace

Drupal\paragraphs_trimmed\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $options = [];
  foreach (filter_formats() as $filter) {
    $options[$filter
      ->id()] = $filter
      ->label();
  }
  $form = parent::settingsForm($form, $form_state) + [
    'summary_field' => [
      '#type' => 'select',
      '#title' => $this
        ->t('Summary Field'),
      '#description' => $this
        ->t('If provided, the value of this field will be used instead of the trimmed paragraphs output.'),
      '#options' => $this
        ->getSummaryFieldOptions(),
      '#default_value' => $this
        ->getSetting('summary_field'),
    ],
    'format' => [
      '#type' => 'select',
      '#title' => $this
        ->t('Text Format'),
      '#description' => $this
        ->t('Select a text format to apply to the rendered paragraphs output before trimming.'),
      '#options' => $options,
      '#default_value' => $this
        ->getSetting('format'),
    ],
  ] + $this->formatter
    ->settingsForm($form, $form_state);
  $form['view_mode']['#description'] = $this
    ->t('Select the view mode to render the paragraphs. This rendered markup will then be trimmed using the following settings.');
  return $form;
}