You are here

public function VotingApiReactionFormatter::settingsForm in Voting API Reaction 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 FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/VotingApiReactionFormatter.php, line 95

Class

VotingApiReactionFormatter
Plugin implementation of the 'votingapi_reaction_default' formatter.

Namespace

Drupal\votingapi_reaction\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  return [
    'show_summary' => [
      '#title' => $this
        ->t('Show reactions summary'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('show_summary'),
    ],
    'show_icon' => [
      '#title' => $this
        ->t('Show reaction icon'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('show_icon'),
    ],
    'show_label' => [
      '#title' => $this
        ->t('Show reaction label'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('show_label'),
    ],
    'show_count' => [
      '#title' => $this
        ->t('Show reaction count'),
      '#type' => 'checkbox',
      '#default_value' => $this
        ->getSetting('show_count'),
    ],
    'sort_reactions' => [
      '#title' => $this
        ->t('Sort reactions'),
      '#type' => 'select',
      '#options' => [
        'none' => $this
          ->t('No sorting'),
        'asc' => $this
          ->t('Asc'),
        'desc' => $this
          ->t('Desc'),
      ],
      '#default_value' => $this
        ->getSetting('sort_reactions'),
    ],
  ] + parent::settingsForm($form, $form_state);
}