protected function WebformTime::formatTextItem in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformTime.php \Drupal\webform\Plugin\WebformElement\WebformTime::formatTextItem()
Format an element's value as text.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
string The element's value formatted as text.
Overrides WebformElementBase::formatTextItem
See also
_webform_token_get_submission_value()
File
- src/
Plugin/ WebformElement/ WebformTime.php, line 59
Class
- WebformTime
- Provides a 'webform_time' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
if (empty($value)) {
return '';
}
$format = $this
->getItemFormat($element);
if ($format === 'value') {
$time_format = isset($element['#time_format']) ? $element['#time_format'] : 'H:i';
return static::formatTime($time_format, strtotime($value));
}
return parent::formatTextItem($element, $webform_submission, $options);
}