Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'custom' Fields showing up with their Label, if _fields.twig is used. #1707

Merged
merged 1 commit into from
Aug 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions templates/helpers/_field_blocks.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{# Sub-block for 'text' field such as 'text', 'textarea', or 'html' #}
{# Sub-block for 'text' field such as 'text', 'textarea', 'html' or 'markdown' #}
{% block text_field %}
<div data-bolt-field="{{ field.name }}">
<{{ tag }}>
Expand All @@ -9,27 +9,15 @@
</div>
{% endblock %}

{# Sub-block for Markdown fields #}
{% block markdown_field %}
<div data-bolt-field="{{ field.name }}">
{{ field.twigValue() }}
</div>
{% endblock %}

{# Block for "basic" fields like HTML, Markdown, Textarea and Text #}
{% block common_fields %}

{# HTML, Textarea, Text fields #}
{% if type in ['html', 'textarea', 'text'] %}
{# HTML, Textarea, Text and Markdown fields #}
{% if type in ['html', 'textarea', 'text', 'markdown'] %}
{% set tag = (field.name in ['title', 'name', 'caption', 'subject', 'heading']) ? 'h3' : 'p' %}
{{ block('text_field') }}
{% endif %}

{# Markdown fields #}
{% if type == 'markdown' %}
{{ block('markdown_field') }}
{% endif %}

{# Image fields #}
{% if type == "image" and field.filename is not empty %}
{{ field|showimage('684') }}
Expand Down Expand Up @@ -84,13 +72,11 @@
{# No special cases defined for other fieldtypes. We just output them if
they're a simple scalar, and 'dump' them otherwise. #}
{% if type not in allfields and field is not empty %}
<p><strong>{{ field|label }}: </strong>
{% if field is iterable %}
{{ dump(field) }}
{% else %}
{{ field.twigValue() }}
{% endif %}
</p>
{% if field is iterable %}
{{ dump(field) }}
{% else %}
{{ field.twigValue() }}
{% endif %}
{% endif %}

{% endblock %}