You are here

public function WebformElementBase::getElementSelectorOptions in Webform 6.x

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

Get an element's selectors as options.

Parameters

array $element: An element.

Return value

array An array of element selectors.

Overrides WebformElementInterface::getElementSelectorOptions

See also

\Drupal\webform\Entity\Webform::getElementsSelectorSourceOption

1 call to WebformElementBase::getElementSelectorOptions()
WebformLikert::getElementSelectorSourceValues in src/Plugin/WebformElement/WebformLikert.php
Get an element's selectors source values.
11 methods override WebformElementBase::getElementSelectorOptions()
ContainerBase::getElementSelectorOptions in src/Plugin/WebformElement/ContainerBase.php
Get an element's selectors as options.
OptionsBase::getElementSelectorOptions in src/Plugin/WebformElement/OptionsBase.php
Table::getElementSelectorOptions in src/Plugin/WebformElement/Table.php
Get an element's selectors as options.
VerticalTabs::getElementSelectorOptions in src/Plugin/WebformElement/VerticalTabs.php
Get an element's selectors as options.
WebformCompositeBase::getElementSelectorOptions in src/Plugin/WebformElement/WebformCompositeBase.php
Get an element's selectors as options.

... See full list

File

src/Plugin/WebformElementBase.php, line 2171

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

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