You are here

protected function WebformUiElementTypeFormBase::buildRow in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_ui/src/Form/WebformUiElementTypeFormBase.php \Drupal\webform_ui\Form\WebformUiElementTypeFormBase::buildRow()

Build element type row.

Parameters

\Drupal\webform\Plugin\WebformElementInterface $webform_element: Webform element plugin.

\Drupal\Core\Url $url: A URL.

string $label: Operation label.

Return value

array A renderable array containing the element type row.

2 calls to WebformUiElementTypeFormBase::buildRow()
WebformUiElementTypeChangeForm::buildForm in modules/webform_ui/src/Form/WebformUiElementTypeChangeForm.php
Form constructor.
WebformUiElementTypeSelectForm::buildForm in modules/webform_ui/src/Form/WebformUiElementTypeSelectForm.php
Form constructor.

File

modules/webform_ui/src/Form/WebformUiElementTypeFormBase.php, line 217

Class

WebformUiElementTypeFormBase
Provides a abstract element type webform for a webform element.

Namespace

Drupal\webform_ui\Form

Code

protected function buildRow(WebformElementInterface $webform_element, Url $url, $label) {
  $row = [];

  // Type.
  $row['type']['link'] = [
    '#type' => 'link',
    '#title' => $webform_element
      ->getPluginLabel(),
    '#url' => $url,
    '#attributes' => WebformDialogHelper::getOffCanvasDialogAttributes($webform_element
      ->getOffCanvasWidth()),
    '#prefix' => '<span class="webform-form-filter-text-source">',
    '#suffix' => '</span>',
  ];
  $row['type']['help'] = [
    '#type' => 'webform_help',
    '#help' => $webform_element
      ->getPluginDescription(),
    '#help_title' => $webform_element
      ->getPluginLabel(),
  ];

  // Preview.
  if ($this
    ->isPreviewEnabled()) {
    $row['preview'] = $this
      ->buildElementPreview($webform_element);
  }

  // Operation.
  $row['operation'] = [
    '#type' => 'link',
    '#title' => $label,
    // Must clone the URL object to prevent the above 'label' link attributes
    // (i.e. webform-tooltip-link) from being copied to 'operation' link.
    '#url' => clone $url,
    '#attributes' => WebformDialogHelper::getOffCanvasDialogAttributes($webform_element
      ->getOffCanvasWidth(), [
      'button',
      'button--primary',
      'button--small',
    ]),
  ];

  // Issue #2741877 Nested modals don't work: when using CKEditor in a
  // modal, then clicking the image button opens another modal,
  // which closes the original modal.
  // @todo Remove the below workaround once this issue is resolved.
  if ($webform_element
    ->getTypeName() === 'processed_text' && !WebformDialogHelper::useOffCanvas()) {
    unset($row['type']['#attributes']);
    unset($row['operation']['#attributes']);
    if (isset($row['operation'])) {
      $row['operation']['#attributes']['class'] = [
        'button',
        'button--primary',
        'button--small',
      ];
    }
    $row['type']['#attributes']['class'][] = 'js-webform-tooltip-link';
    $row['type']['#attributes']['class'][] = 'webform-tooltip-link';
    $row['type']['#attributes']['title'] = $webform_element
      ->getPluginDescription();
  }
  return $row;
}