You are here

protected function YamlFormTableTrait::getTableSelectElementSelectorOptions in YAML Form 8

2 calls to YamlFormTableTrait::getTableSelectElementSelectorOptions()
TableSelect::getElementSelectorOptions in src/Plugin/YamlFormElement/TableSelect.php
Get an element's selectors as options.
YamlFormTableSelectSort::getElementSelectorOptions in src/Plugin/YamlFormElement/YamlFormTableSelectSort.php
Get an element's selectors as options.

File

src/Plugin/YamlFormElement/YamlFormTableTrait.php, line 75

Class

YamlFormTableTrait
Provides a 'table' trait.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

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