Skip to content

Commit

Permalink
Update field template for field label
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Feb 10, 2024
1 parent ac8f19f commit cabe7d0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ third_party_settings:
field_label:
label_class: ''
label_value: ''
label_tag: h3
label_tag: ''
weight: 9
additional: { }
a69dd40a-c1a3-4266-b0ce-7efdaaa137fe:
Expand Down Expand Up @@ -386,7 +386,7 @@ third_party_settings:
field_label:
label_class: ''
label_value: ''
label_tag: h3
label_tag: ''
weight: 5
additional: { }
0cff0fa4-edcc-4bae-93bf-865242051b35:
Expand Down
37 changes: 35 additions & 2 deletions themes/stanford_basic/templates/core/field.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{% extends "@stable9/field/field.html.twig" %}

{# Create classes array #}
{% set classes = [] %}

Expand All @@ -11,3 +9,38 @@
#}

{% set attributes = attributes.addClass(classes) %}

{%
set title_classes = [
label_display == 'visually_hidden' ? 'visually-hidden',
]
%}
{% set label_tag = label_tag|default('div') %}


{% if label_hidden %}
{% if multiple %}
<div{{ attributes }}>
{% for item in items %}
<div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}
</div>
{% else %}
{% for item in items %}
<div{{ attributes }}>{{ item.content }}</div>
{% endfor %}
{% endif %}
{% else %}
<div{{ attributes }}>
<{{ label_tag }}{{ title_attributes.addClass(title_classes) }}>{{ label }}</{{ label_tag }}>
{% if multiple %}
<div>
{% endif %}
{% for item in items %}
<div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}
{% if multiple %}
</div>
{% endif %}
</div>
{% endif %}

0 comments on commit cabe7d0

Please sign in to comment.