You are here

public function FacebookCommentsFormatter::settingsForm in Facebook Comments Social Plugin 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/FacebookCommentsFormatter.php, line 37

Class

FacebookCommentsFormatter
Plugin implementation of the 'facebook_comments' formatter.

Namespace

Drupal\facebook_comments\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = array();
  $element['facebook_comments_style'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Color Scheme'),
    '#default_value' => $this
      ->getSetting('facebook_comments_style'),
    '#options' => array(
      'light' => $this
        ->t('Light'),
      'dark' => $this
        ->t('Dark'),
    ),
  );
  $element['facebook_comments_width'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Facebook comment plugin width'),
    '#default_value' => $this
      ->getSetting('facebook_comments_width'),
    '#description' => $this
      ->t('The width of the Facebook comment plugin in pixels. Example: 620'),
  );
  $element['facebook_comments_width_fluid'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Fluid Facebook comment plugin width'),
    '#default_value' => $this
      ->getSetting('facebook_comments_width_fluid'),
    '#description' => $this
      ->t('Make the width of the Facebook comment plugin fluid (100%).<br/>This overrules the width setting above.'),
  );
  $element['facebook_comments_amount'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Amount of comments to display'),
    '#options' => array(
      1 => 1,
      2 => 2,
      3 => 3,
      5 => 5,
      7 => 7,
      10 => 10,
      15 => 15,
      20 => 20,
      30 => 30,
    ),
    '#default_value' => $this
      ->getSetting('facebook_comments_amount'),
  );
  return $element;
}