You are here

public function IframeUrlheightWidget::formElement in Iframe 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/IframeUrlheightWidget.php \Drupal\iframe\Plugin\Field\FieldWidget\IframeUrlheightWidget::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/IframeUrlheightWidget.php, line 22

Class

IframeUrlheightWidget
Class IframeUrlheightWidget.

Namespace

Drupal\iframe\Plugin\Field\FieldWidget

Code

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

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