public function YamlFormMarkupBase::buildHtml in YAML Form 8
Build an element as HTML element.
Parameters
array $element: An element.
array|mixed $value: A value.
array $options: An array of options.
Return value
array A render array representing an element as HTML.
Overrides YamlFormElementBase::buildHtml
File
- src/
Plugin/ YamlFormElement/ YamlFormMarkupBase.php, line 53
Class
- YamlFormMarkupBase
- Provides a base 'markup' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function buildHtml(array &$element, $value, array $options = []) {
// Hide markup element if it should be only displayed on a 'form'.
if (empty($element['#display_on']) || $element['#display_on'] == 'form') {
return [];
}
// Since we are not passing this element to the
// yamlform_container_base_html template we need to replace the default
// sub elements with the value (ie renderable sub elements).
if (is_array($value)) {
$element = $value + $element;
}
return $element;
}