Refator duplicate field_name code

This commit is contained in:
Andy Miller
2017-05-15 14:49:18 -06:00
parent cde4ac5f7b
commit 422aff070c

View File

@@ -3,6 +3,7 @@
{% set isDisabledToggleable = field.toggleable and not toggleableChecked %}
{% set value = (value is null ? field.default : value) %}
{% set vertical = field.style == 'vertical' %}
{% set field_name = (scope ~ field.name)|fieldName %}
{% if field.yaml and value is iterable %}
{% set value = value|toYaml %}
@@ -13,11 +14,11 @@
{% block contents %}
<div class="form-label{% if not vertical %} block size-1-3{% endif %}">
{% if field.toggleable %}
<span class="checkboxes toggleable" data-grav-field="toggleable" data-grav-field-name="{{ (scope ~ field.name)|fieldName }}">
<span class="checkboxes toggleable" data-grav-field="toggleable" data-grav-field-name="{{ field_name }}">
<input type="checkbox"
id="toggleable_{{ field.name }}"
{% if toggleableChecked %}value="1"{% endif %}
name="toggleable_{{ (scope ~ field.name)|fieldName }}"
name="toggleable_{{ field_name }}"
{% if toggleableChecked %}checked="checked"{% endif %}
>
<label for="toggleable_{{ field.name }}"></label>
@@ -47,7 +48,7 @@
{% block prepend %}{% endblock prepend %}
<input
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
name="{{ field_name }}"
value="{{ value|join(', ') }}"
{# input attribute structures #}
{% block input_attributes %}