You are here

public function FacebookCommentsBlock::blockForm in Facebook Comments Social Plugin 8

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The renderable form array representing the entire configuration form.

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/FacebookCommentsBlock.php, line 89

Class

FacebookCommentsBlock
Provides a Facebook Comments Block

Namespace

Drupal\facebook_comments\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['facebook_comments_style'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Color Scheme'),
    '#default_value' => isset($config['facebook_comments_style']) ? $config['facebook_comments_style'] : 'light',
    '#options' => array(
      'light' => $this
        ->t('Light'),
      'dark' => $this
        ->t('Dark'),
    ),
  );
  $form['facebook_comments_width'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Facebook comment plugin width'),
    '#default_value' => isset($config['facebook_comments_width']) ? $config['facebook_comments_width'] : 208,
    '#description' => $this
      ->t('The width of the Facebook comment plugin for this block, in pixels. Example: 208'),
  );
  $form['facebook_comments_width_fluid'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Fluid Facebook comment plugin width'),
    '#default_value' => isset($config['facebook_comments_width_fluid']) ? $config['facebook_comments_width_fluid'] : 1,
    '#description' => $this
      ->t('Make the width of the Facebook comment plugin for this block fluid (100%). This overrules the block width setting above.'),
  );
  $form['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' => isset($config['facebook_comments_amount']) ? $config['facebook_comments_amount'] : 5,
  );
  return $form;
}