You are here

public function Target::buildFormElement in Linkit 8.4

The form element structure for this attribute to be used in the dialog.

Parameters

mixed $default_value: The default value for the element. Used when editing an attribute in the dialog.

Return value

array The form element.

Overrides AttributeInterface::buildFormElement

File

src/Plugin/Linkit/Attribute/Target.php, line 30
Contains \Drupal\linkit\Plugin\Linkit\Attribute\Target.

Class

Target
Target attribute.

Namespace

Drupal\linkit\Plugin\Linkit\Attribute

Code

public function buildFormElement($default_value) {
  switch ($this->configuration['widget_type']) {
    case self::SELECT_LIST:
      return [
        '#type' => 'select',
        '#title' => t('Target'),
        '#options' => [
          '' => '',
          '_blank' => t('New window (_blank)'),
          '_top' => t('Top window (_top)'),
          '_self' => t('Same window (_self)'),
          '_parent' => t('Parent window (_parent)'),
        ],
        '#default_value' => $default_value,
      ];
    case self::SIMPLE_CHECKBOX:
      return [
        '#type' => 'checkbox',
        '#title' => t('Open in new window'),
        '#default_value' => $default_value,
        '#return_value' => '_blank',
      ];
  }
  return [];
}