public function YamlFormCompositeBase::getElementSelectorOptions in YAML Form 8
Get an element's selectors as options.
Parameters
array $element: An element.
Return value
array An array of element selectors.
Overrides YamlFormElementBase::getElementSelectorOptions
File
- src/
Plugin/ YamlFormElement/ YamlFormCompositeBase.php, line 187
Class
- YamlFormCompositeBase
- Provides a base for composite elements.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function getElementSelectorOptions(array $element) {
$title = $this
->getAdminLabel($element) . ' [' . $this
->getPluginLabel() . ']';
$name = $element['#yamlform_key'];
$selectors = [];
$composite_elements = $this
->getInitializedCompositeElement($element);
foreach ($composite_elements as $composite_key => $composite_element) {
$has_access = !isset($composite_elements['#access']) || $composite_elements['#access'];
if ($has_access && isset($composite_element['#type'])) {
$element_handler = $this->elementManager
->getElementInstance($composite_element);
$composite_title = isset($composite_element['#title']) ? $composite_element['#title'] : $composite_key;
switch ($composite_element['#type']) {
case 'label':
case 'yamlform_message':
break;
case 'yamlform_select_other':
$selectors[":input[name=\"{$name}[{$composite_key}][select]\"]"] = $composite_title . ' [' . $this
->t('Select') . ']';
$selectors[":input[name=\"{$name}[{$composite_key}][other]\"]"] = $composite_title . ' [' . $this
->t('Textfield') . ']';
break;
default:
$selectors[":input[name=\"{$name}[{$composite_key}]\"]"] = $composite_title . ' [' . $element_handler
->getPluginLabel() . ']';
break;
}
}
}
return [
$title => $selectors,
];
}