Closed laurencefass closed 5 years ago
actual example i've mapped a string select box to
yaml pattern field:
...
pattern_field:
type: 'text'
label: 'Entry position'
description: 'Set overlay entrance position (top, bottom, left, right, fade)'
preview: 'entry-right'
html.twig file: {% set classes= ['custom_class', pattern_field] %} <div {{ attributes.addClass(classes) }}>
results: {{ pattern_field }} outputs select list selection works ok. html output replaced pattern_field with 'Array'
Drupal UI Notice: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 73 of core/lib/Drupal/Core/Template/AttributeArray.php).
discovered this is a more general question about drupal and twig.
I want to use drupal fields to define class names in ui_patterns. i.e. define a field in a pattern twig.html file and use its {{ twig variable }} as a class name. The following doesn't work. Is there a correct way of doing this? even possible?
{% set classes = [ 'class_name_1', 'class_name_2', {{ ui_pattern_field_name }}, ] %} <div{{ attributes.addClass(classes) }}>