public function WebformCompositeBase::getElementSelectorOptions in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::getElementSelectorOptions()
Get an element's selectors as options.
Parameters
array $element: An element.
Return value
array An array of element selectors.
Overrides WebformElementBase::getElementSelectorOptions
See also
\Drupal\webform\Entity\Webform::getElementsSelectorSourceOption
File
- src/
Plugin/ WebformElement/ WebformCompositeBase.php, line 290
Class
- WebformCompositeBase
- Provides a base for composite elements.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function getElementSelectorOptions(array $element) {
if ($this
->hasMultipleValues($element)) {
return [];
}
$title = $this
->getAdminLabel($element) . ' [' . $this
->getPluginLabel() . ']';
$name = $element['#webform_key'];
$selectors = [];
$composite_elements = $this
->getInitializedCompositeElement($element);
foreach ($composite_elements as $composite_key => $composite_element) {
if (Element::isVisibleElement($composite_elements) && isset($composite_element['#type'])) {
$element_plugin = $this->elementManager
->getElementInstance($composite_element);
$composite_element['#webform_key'] = "{$name}[{$composite_key}]";
$selectors += OptGroup::flattenOptions($element_plugin
->getElementSelectorOptions($composite_element));
}
}
return [
$title => $selectors,
];
}