You are here

public function OptionsBase::getElementSelectorSourceValues in Webform 6.x

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

Get an element's selectors source values.

Parameters

array $element: An element.

Return value

array An array of element selectors source values.

Overrides WebformElementBase::getElementSelectorSourceValues

See also

\Drupal\webform\Entity\Webform::getElementsSelectorSourceValues

1 call to OptionsBase::getElementSelectorSourceValues()
WebformOptionsCustom::getElementSelectorSourceValues in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Get an element's selectors source values.
2 methods override OptionsBase::getElementSelectorSourceValues()
Checkboxes::getElementSelectorSourceValues in src/Plugin/WebformElement/Checkboxes.php
Get an element's selectors source values.
WebformOptionsCustom::getElementSelectorSourceValues in modules/webform_options_custom/src/Plugin/WebformElement/WebformOptionsCustom.php
Get an element's selectors source values.

File

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

Class

OptionsBase
Provides a base 'options' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getElementSelectorSourceValues(array $element) {
  if ($this
    ->hasMultipleValues($element) && $this
    ->hasMultipleWrapper()) {
    return [];
  }
  $plugin_id = $this
    ->getPluginId();
  $name = $element['#webform_key'];
  $options = OptGroup::flattenOptions($element['#options']);
  if ($this
    ->getElementSelectorInputsOptions($element)) {
    $other_type = $this
      ->getOptionsOtherType();
    $multiple = $this
      ->hasMultipleValues($element) && $other_type === 'select' ? '[]' : '';
    return [
      ":input[name=\"{$name}[{$other_type}]{$multiple}\"]" => $options,
    ];
  }
  else {
    $multiple = $this
      ->hasMultipleValues($element) && strpos($plugin_id, 'select') !== FALSE ? '[]' : '';
    return [
      ":input[name=\"{$name}{$multiple}\"]" => $options,
    ];
  }
}