public static function WebformTableTrait::getTableSelectOptionTitle in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformTableTrait.php \Drupal\webform\Plugin\WebformElement\WebformTableTrait::getTableSelectOptionTitle()
Get table selection option title/text.
Issue #2719453: Tableselect single radio button missing #title attribute and is not accessible,
Parameters
array $option: A table select option.
Return value
string|\Drupal\Component\Render\MarkupInterface|null Table selection option title/text.
See also
https://www.drupal.org/project/drupal/issues/2719453
1 call to WebformTableTrait::getTableSelectOptionTitle()
- WebformTableTrait::processTableSelectOptions in src/
Plugin/ WebformElement/ WebformTableTrait.php - Process table selected options.
File
- src/
Plugin/ WebformElement/ WebformTableTrait.php, line 220
Class
- WebformTableTrait
- Provides a 'table' trait.
Namespace
Drupal\webform\Plugin\WebformElementCode
public static function getTableSelectOptionTitle(array $option) {
if (is_array($option) && WebformArrayHelper::isAssociative($option)) {
// Get first value from custom options.
$title = reset($option);
if (is_array($title)) {
$title = \Drupal::service('renderer')
->render($title);
}
return $title;
}
elseif (is_array($option) && !empty($option[0]['value'])) {
// Get value from default options.
// @see \Drupal\webform\Plugin\WebformElement\WebformTableTrait::prepare
return $option[0]['value'];
}
else {
return NULL;
}
}