public function WebformMarkupBase::buildHtml in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformMarkupBase.php \Drupal\webform\Plugin\WebformElement\WebformMarkupBase::buildHtml()
Build an element as HTML element.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array A render array representing an element as HTML.
Overrides WebformDisplayOnTrait::buildHtml
File
- src/
Plugin/ WebformElement/ WebformMarkupBase.php, line 75
Class
- WebformMarkupBase
- Provides a base 'markup' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function buildHtml(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
// Hide element if it should not be displayed on 'view'.
if (!$this
->isDisplayOn($element, WebformElementDisplayOnInterface::DISPLAY_ON_VIEW)) {
return [];
}
if ($this
->isContainer($element)) {
/** @var \Drupal\webform\WebformSubmissionViewBuilderInterface $view_builder */
$view_builder = $this->entityTypeManager
->getViewBuilder('webform_submission');
$value = $view_builder
->buildElements($element, $webform_submission, $options, 'html');
// Since we are not passing this element to the
// webform_container_base_html template we need to replace the default
// sub elements with the value (i.e. renderable sub elements).
if (is_array($value)) {
$element = $value + $element;
}
}
return $element;
}