You are here

public function OptionsBase::getElementSelectorOptions in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/OptionsBase.php \Drupal\webform\Plugin\WebformElement\OptionsBase::getElementSelectorOptions()

Overrides WebformElementBase::getElementSelectorOptions

See also

\Drupal\webform\Entity\Webform::getElementsSelectorOptions

4 methods override OptionsBase::getElementSelectorOptions()
TableSelect::getElementSelectorOptions in src/Plugin/WebformElement/TableSelect.php
Get an element's selectors as options.
WebformCheckboxesOther::getElementSelectorOptions in src/Plugin/WebformElement/WebformCheckboxesOther.php
Get an element's selectors as options.
WebformTableSelectSort::getElementSelectorOptions in src/Plugin/WebformElement/WebformTableSelectSort.php
Get an element's selectors as options.
WebformTableSort::getElementSelectorOptions in src/Plugin/WebformElement/WebformTableSort.php
Get an element's selectors as options.

File

src/Plugin/WebformElement/OptionsBase.php, line 727

Class

OptionsBase
Provides a base 'options' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getElementSelectorOptions(array $element) {
  if ($this
    ->hasMultipleValues($element) && $this
    ->hasMultipleWrapper()) {
    return [];
  }
  $plugin_id = $this
    ->getPluginId();
  $title = $this
    ->getAdminLabel($element) . ' [' . $this
    ->getPluginLabel() . ']';
  $name = $element['#webform_key'];
  if ($inputs = $this
    ->getElementSelectorInputsOptions($element)) {
    $selectors = [];
    foreach ($inputs as $input_name => $input_title) {
      $multiple = $this
        ->hasMultipleValues($element) && $input_name === 'select' ? '[]' : '';
      $selectors[":input[name=\"{$name}[{$input_name}]{$multiple}\"]"] = $input_title;
    }
    return [
      $title => $selectors,
    ];
  }
  else {
    $multiple = $this
      ->hasMultipleValues($element) && strpos($plugin_id, 'select') !== FALSE ? '[]' : '';
    return [
      ":input[name=\"{$name}{$multiple}\"]" => $title,
    ];
  }
}