public function YamlFormEntityReferenceTrait::formatHtml in YAML Form 8
File
- src/
Plugin/ YamlFormElement/ YamlFormEntityReferenceTrait.php, line 37
Class
- YamlFormEntityReferenceTrait
- Provides an 'entity_reference' trait.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function formatHtml(array &$element, $value, array $options = []) {
if (empty($value)) {
return '';
}
$format = $this
->getFormat($element);
switch ($format) {
case 'raw':
case 'id':
case 'label':
case 'text':
$items = $this
->formatItems($element, $value, $options);
if ($this
->isMultiline($element)) {
return [
'#theme' => 'item_list',
'#items' => $items,
];
}
else {
return implode('; ', $items);
}
case 'link':
return $this
->formatLinks($element, $value, $options);
default:
return $this
->formatView($element, $value, $options);
}
}