You are here

public function IframeWidgetBase::settingsForm in Iframe 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/IframeWidgetBase.php \Drupal\iframe\Plugin\Field\FieldWidget\IframeWidgetBase::settingsForm()

It is .

Used : at "Manage form display" after work-symbol.

Overrides WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/IframeWidgetBase.php, line 56

Class

IframeWidgetBase
Plugin implementation base functions.

Namespace

Drupal\iframe\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {

  /* Settings form after "manage form display" page, valid for one content type */
  $field_settings = $this
    ->getFieldSettings();
  $settings = $this
    ->getSettings();
  $values = [];
  $values = $settings + $field_settings + self::defaultSettings();

  // \iframe_debug(0, 'manage settingsForm field_settings', $field_settings);
  // \iframe_debug(0, 'manage settingsForm settings', $settings);
  // \iframe_debug(0, 'manage settingsForm values', $values);
  $element['width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Iframe Width'),
    // ''
    '#default_value' => isset($values['width']) ? $values['width'] : '',
    '#description' => self::getSizedescription(),
    '#maxlength' => 4,
    '#size' => 4,
  ];
  $element['height'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Iframe Height'),
    // ''
    '#default_value' => isset($values['height']) ? $values['height'] : '',
    '#description' => self::getSizedescription(),
    '#maxlength' => 4,
    '#size' => 4,
  ];
  $element['class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Additional CSS Class'),
    // ''
    '#default_value' => isset($values['class']) ? $values['class'] : '',
    '#description' => $this
      ->t('When output, this iframe will have this class attribute. Multiple classes should be separated by spaces.'),
  ];
  $element['expose_class'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Expose Additional CSS Class'),
    // 0
    '#default_value' => isset($values['expose_class']) ? $values['expose_class'] : '',
    '#description' => $this
      ->t('Allow author to specify an additional class attribute for this iframe.'),
  ];
  $element['frameborder'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Frameborder'),
    '#options' => [
      '0' => $this
        ->t('No frameborder'),
      '1' => $this
        ->t('Show frameborder'),
    ],
    // 0
    '#default_value' => isset($values['frameborder']) ? $values['frameborder'] : '0',
    '#description' => $this
      ->t('Frameborder is the border around the iframe. Most people want it removed, so the default value for frameborder is zero (0), or no border.'),
  ];
  $element['scrolling'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Scrolling'),
    '#options' => [
      'auto' => $this
        ->t('Automatic'),
      'no' => $this
        ->t('Disabled'),
      'yes' => $this
        ->t('Enabled'),
    ],
    // 'auto'
    '#default_value' => isset($values['scrolling']) ? $values['scrolling'] : 'auto',
    '#description' => $this
      ->t('Scrollbars help the user to reach all iframe content despite the real height of the iframe content. Please disable it only if you know what you are doing.'),
  ];
  $element['transparency'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Transparency'),
    '#options' => [
      '0' => $this
        ->t('No transparency'),
      '1' => $this
        ->t('Allow transparency'),
    ],
    // 0
    '#default_value' => isset($values['transparency']) ? $values['transparency'] : '0',
    '#description' => $this
      ->t('Allow transparency per CSS in the outer iframe tag. You have to set background-color:transparent in your iframe body tag too!'),
  ];
  $element['tokensupport'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Token Support'),
    '#options' => [
      '0' => $this
        ->t('No tokens allowed'),
      '1' => $this
        ->t('Tokens only in title field'),
      '2' => $this
        ->t('Tokens for title and URL field'),
    ],
    // 0
    '#default_value' => isset($values['tokensupport']) ? $values['tokensupport'] : '0',
    '#description' => $this
      ->t('Are tokens allowed for users to use in title or URL field?'),
  ];
  $element['allowfullscreen'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Allow fullscreen'),
    '#options' => [
      '0' => $this
        ->t('false'),
      '1' => $this
        ->t('true'),
    ],
    // 0
    '#default_value' => isset($values['allowfullscreen']) ? $values['allowfullscreen'] : '0',
    '#description' => $this
      ->t('Allow fullscreen for iframe. The iframe can activate fullscreen mode by calling the requestFullscreen() method.'),
  ];
  if (!\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $element['tokensupport']['#description'] .= ' ' . $this
      ->t('Attention: Token module is not currently enabled!');
  }
  return $element;
}