You are here

public function IframeUrlWidget::formElement in Iframe 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/IframeUrlWidget.php \Drupal\iframe\Plugin\Field\FieldWidget\IframeUrlWidget::formElement()

It is .

Used: (1) at admin edit fields.

Used: (2) at add-story for creation content.

Overrides IframeWidgetBase::formElement

File

src/Plugin/Field/FieldWidget/IframeUrlWidget.php, line 22

Class

IframeUrlWidget
Plugin implementation of the 'Iframe' widget with URL.

Namespace

Drupal\iframe\Plugin\Field\FieldWidget

Code

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  $this->allowedAttributes['width'] = 0;
  $this->allowedAttributes['height'] = 0;
  $elements = parent::formElement($items, $delta, $element, $form, $form_state);

  // Dont show, only save default value.
  $elements['width']['#type'] = 'value';

  // Dont show, only save default value.
  $elements['height']['#type'] = 'value';
  unset($element['width']['#required']);
  unset($element['height']['#required']);
  return $elements;
}