You are here

public function IframeItem::fieldSettingsForm in Iframe 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/IframeItem.php \Drupal\iframe\Plugin\Field\FieldType\IframeItem::fieldSettingsForm()

Global field settings for iframe field.

In contenttype-field-settings "Manage fields" -> "Edit" admin/structure/types/manage/CONTENTTYPE/fields/node.CONTENTTYPE.FIELDNAME.

Overrides FieldItemBase::fieldSettingsForm

File

src/Plugin/Field/FieldType/IframeItem.php, line 171

Class

IframeItem
Plugin implementation of the 'Iframe' field type.

Namespace

Drupal\iframe\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = [];
  $settings = $this
    ->getSettings() + self::defaultFieldSettings();

  // \iframe_debug(4, __METHOD__ . " settings", $settings);
  $element['class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('CSS Class'),
    // ''
    '#default_value' => $settings['class'],
  ];
  $element['frameborder'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Frameborder'),
    // '0'
    '#default_value' => $settings['frameborder'],
    '#options' => [
      '0' => $this
        ->t('No frameborder'),
      '1' => $this
        ->t('Show frameborder'),
    ],
  ];
  $element['scrolling'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Scrolling'),
    // 'auto'
    '#default_value' => $settings['scrolling'],
    '#options' => [
      'auto' => $this
        ->t('Automatic'),
      'no' => $this
        ->t('Disabled'),
      'yes' => $this
        ->t('Enabled'),
    ],
  ];
  $element['transparency'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Transparency'),
    // '0'
    '#default_value' => $settings['transparency'],
    '#options' => [
      '0' => $this
        ->t('No transparency'),
      '1' => $this
        ->t('Allow transparency'),
    ],
    '#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['allowfullscreen'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Allow fullscreen'),
    '#options' => [
      '0' => $this
        ->t('false'),
      '1' => $this
        ->t('true'),
    ],
    // 0
    '#default_value' => $settings['allowfullscreen'],
    '#description' => $this
      ->t('Allow fullscreen for iframe. The iframe can activate fullscreen mode by calling the requestFullscreen() method.'),
  ];
  $element['tokensupport'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Token Support'),
    // '0'
    '#default_value' => $settings['tokensupport'],
    '#options' => [
      '0' => $this
        ->t('No tokens allowed'),
      '1' => $this
        ->t('Tokens only in title field'),
      '2' => $this
        ->t('Tokens for title and URL field'),
    ],
    '#description' => $this
      ->t('Are tokens allowed for users to use in title or URL field?'),
  ];
  if (!\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $element['tokensupport']['#description'] .= ' ' . t('Attention: Token module is not currently enabled!');
  }
  return $element;
}