You are here

protected function WebformTableTrait::getTableSelectElementSelectorOptions in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformTableTrait.php \Drupal\webform\Plugin\WebformElement\WebformTableTrait::getTableSelectElementSelectorOptions()
2 calls to WebformTableTrait::getTableSelectElementSelectorOptions()
TableSelect::getElementSelectorOptions in src/Plugin/WebformElement/TableSelect.php
Get an element's selectors as options.
WebformTableSelectSort::getElementSelectorOptions in src/Plugin/WebformElement/WebformTableSelectSort.php
Get an element's selectors as options.

File

src/Plugin/WebformElement/WebformTableTrait.php, line 96

Class

WebformTableTrait
Provides a 'table' trait.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function getTableSelectElementSelectorOptions(array $element, $input_selector = '') {
  $title = $this
    ->getAdminLabel($element) . ' [' . $this
    ->getPluginLabel() . ']';
  $name = $element['#webform_key'];
  if ($this
    ->hasMultipleValues($element)) {
    $selectors = [];
    foreach ($element['#options'] as $value => $text) {
      if (is_array($text)) {
        $text = $value;
      }
      $selectors[":input[name=\"{$name}[{$value}]{$input_selector}\"]"] = $text . ' [' . $this
        ->t('Checkbox') . ']';
    }
    return [
      $title => $selectors,
    ];
  }
  else {
    return [
      ":input[name=\"{$name}\"]" => $title,
    ];
  }
}