public static function WebformElementHelper::convertToString in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Utility/WebformElementHelper.php \Drupal\webform\Utility\WebformElementHelper::convertToString()
Convert element or property to a string.
This method is used to prevent 'Array to string conversion' errors.
Parameters
array|string|MarkupInterface $element: An element, render array, string, or markup.
Return value
string The element or property to a string.
1 call to WebformElementHelper::convertToString()
- OptionsBase::prepare in src/
Plugin/ WebformElement/ OptionsBase.php - Prepare an element to be rendered within a webform.
File
- src/
Utility/ WebformElementHelper.php, line 657
Class
- WebformElementHelper
- Helper class webform element methods.
Namespace
Drupal\webform\UtilityCode
public static function convertToString($element) {
if (is_array($element)) {
return (string) \Drupal::service('renderer')
->renderPlain($element);
}
else {
return (string) $element;
}
}