You are here

public function SharethisWidgetBlock::blockForm in ShareThis 8.2

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/SharethisWidgetBlock.php, line 132

Class

SharethisWidgetBlock
Provides an 'Share this Widget' block.

Namespace

Drupal\sharethis\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $description = $this
    ->t('Variable - Different per URL');
  $description .= '<br />';
  $description .= $this
    ->t('External - Useful in iframes (Facebook Tabs, etc.)');
  $form['sharethis_path'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Path to share'),
    '#options' => [
      'global' => $this
        ->t('Global'),
      'current' => $this
        ->t('Variable'),
      'external' => $this
        ->t('External URL'),
    ],
    '#description' => $description,
    '#default_value' => $this->configuration['sharethis_path'],
  ];
  $form['sharethis_path_external'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('External URL'),
    '#default_value' => $this->configuration['sharethis_path_external'],
    '#states' => [
      'visible' => [
        ':input[name="settings[sharethis_path]"]' => [
          'value' => 'external',
        ],
      ],
    ],
  ];
  return $form;
}