protected function WebformElementBase::format in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::format()
Format an element's value as HTML or plain text.
Parameters
string $type: The format type, HTML or Text.
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array|string The element's value formatted as plain text or a render array.
2 calls to WebformElementBase::format()
- WebformElementBase::formatHtml in src/
Plugin/ WebformElementBase.php - Format an element's value as HTML.
- WebformElementBase::formatText in src/
Plugin/ WebformElementBase.php - Format an element's value as plain text.
2 methods override WebformElementBase::format()
- Table::format in src/
Plugin/ WebformElement/ Table.php - Format an element's value as HTML or plain text.
- WebformTable::format in src/
Plugin/ WebformElement/ WebformTable.php - Format an element's value as HTML or plain text.
File
- src/
Plugin/ WebformElementBase.php, line 1402
Class
- WebformElementBase
- Provides a base class for a webform element.
Namespace
Drupal\webform\PluginCode
protected function format($type, array &$element, WebformSubmissionInterface $webform_submission, array $options = []) {
if (!$this
->hasValue($element, $webform_submission, $options) && !$this
->isContainer($element)) {
return '';
}
$item_function = 'format' . $type . 'Item';
$items_function = 'format' . $type . 'Items';
if ($this
->hasMultipleValues($element)) {
// Return $options['delta'] which is used by tokens.
// @see _webform_token_get_submission_value()
if (isset($options['delta'])) {
return $this
->{$item_function}($element, $webform_submission, $options);
}
elseif ($this
->getItemsFormat($element) === 'custom' && !empty($element['#format_items_' . strtolower($type)])) {
return $this
->formatCustomItems($type, $element, $webform_submission, $options);
}
else {
return $this
->{$items_function}($element, $webform_submission, $options);
}
}
else {
if ($this
->getItemFormat($element) === 'custom' && !empty($element['#format_' . strtolower($type)])) {
return $this
->formatCustomItem($type, $element, $webform_submission, $options);
}
else {
return $this
->{$item_function}($element, $webform_submission, $options);
}
}
}