protected function WebformOptionsListBuilder::buildOptions in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformOptionsListBuilder.php \Drupal\webform\WebformOptionsListBuilder::buildOptions()
Build list of webform options.
Parameters
\Drupal\webform\WebformOptionsInterface $webform_options: A webform options entity.
Return value
string Semi-colon delimited list of webform options.
1 call to WebformOptionsListBuilder::buildOptions()
- WebformOptionsListBuilder::buildRow in src/
WebformOptionsListBuilder.php - Builds a row for an entity in the entity listing.
File
- src/
WebformOptionsListBuilder.php, line 216
Class
- WebformOptionsListBuilder
- Defines a class to build a listing of webform options entities.
Namespace
Drupal\webformCode
protected function buildOptions(WebformOptionsInterface $webform_options) {
$element = [
'#options' => $webform_options
->id(),
];
$options = WebformOptions::getElementOptions($element);
$options = OptGroup::flattenOptions($options);
foreach ($options as $key => &$value) {
if ($key !== $value) {
$value .= ' (' . $key . ')';
}
}
return implode('; ', array_slice($options, 0, 12)) . (count($options) > 12 ? '; …' : '');
}