protected function YamlFormCompositeBase::formatLines in YAML Form 8
Format composite element value into lines of text.
Parameters
array $element: A composite element.
array $value: Composite element values.
Return value
array Composite element values converted into lines of text.
2 calls to YamlFormCompositeBase::formatLines()
- YamlFormCompositeBase::formatHtml in src/
Plugin/ YamlFormElement/ YamlFormCompositeBase.php - Format an element's value as HTML.
- YamlFormCompositeBase::formatText in src/
Plugin/ YamlFormElement/ YamlFormCompositeBase.php - Format an element's value as plain text.
2 methods override YamlFormCompositeBase::formatLines()
- YamlFormAddress::formatLines in src/
Plugin/ YamlFormElement/ YamlFormAddress.php - Format composite element value into lines of text.
- YamlFormName::formatLines in src/
Plugin/ YamlFormElement/ YamlFormName.php - Format composite element value into lines of text.
File
- src/
Plugin/ YamlFormElement/ YamlFormCompositeBase.php, line 71
Class
- YamlFormCompositeBase
- Provides a base for composite elements.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
protected function formatLines(array $element, array $value) {
$items = [];
$composite_elements = $this
->getInitializedCompositeElement($element);
foreach (RenderElement::children($composite_elements) as $composite_key) {
if (isset($value[$composite_key]) && $value[$composite_key] != '') {
$composite_element = $composite_elements[$composite_key];
$composite_title = $composite_element['#title'];
$composite_value = $value[$composite_key];
$items[$composite_key] = "<b>{$composite_title}:</b> {$composite_value}";
}
}
return $items;
}