2015-06-01 21:22:56 +02:00
|
|
|
{% extends "forms/field.html.twig" %}
|
2014-09-10 14:49:57 -06:00
|
|
|
|
2016-03-15 21:36:14 +02:00
|
|
|
{% macro renderer(key, text, field, scope) %}
|
2017-05-15 15:08:26 -06:00
|
|
|
|
|
|
|
|
{% if text is not iterable %}
|
2018-08-16 15:06:18 -07:00
|
|
|
<div class="form-row{% if field.value_only %} array-field-value_only{% endif %}"
|
|
|
|
|
data-grav-array-type="row">
|
|
|
|
|
<span data-grav-array-action="sort" class="fa fa-bars"></span>
|
|
|
|
|
{% if field.value_only != true %}
|
|
|
|
|
{% if key == '0' and text == '' %}
|
|
|
|
|
{% set key = '' %}
|
|
|
|
|
{% endif %}
|
2015-09-08 11:38:21 +02:00
|
|
|
|
2018-08-16 15:06:18 -07:00
|
|
|
<input
|
2018-08-26 11:49:11 +03:00
|
|
|
data-grav-array-type="key"
|
|
|
|
|
type="text" value="{{ key }}"
|
|
|
|
|
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
2021-08-18 14:12:03 +03:00
|
|
|
placeholder="{{ field.placeholder_key|t }}" />
|
2018-08-16 15:06:18 -07:00
|
|
|
{% endif %}
|
2015-09-08 11:38:21 +02:00
|
|
|
|
2018-08-16 15:06:18 -07:00
|
|
|
{% if field.value_type == 'textarea' %}
|
|
|
|
|
<textarea
|
2018-08-26 11:49:11 +03:00
|
|
|
data-grav-array-type="value"
|
|
|
|
|
name="{{ ((scope ~ field.name)|fieldName) ~ '[' ~ key ~ ']' }}"
|
2021-08-18 14:12:03 +03:00
|
|
|
placeholder="{{ field.placeholder_value|t }}"
|
2018-08-26 11:49:11 +03:00
|
|
|
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}>{{ text }}</textarea>
|
2018-08-16 15:06:18 -07:00
|
|
|
{% else %}
|
|
|
|
|
<input
|
2018-08-26 11:49:11 +03:00
|
|
|
data-grav-array-type="value"
|
|
|
|
|
type="text"
|
|
|
|
|
name="{{ ((scope ~ field.name)|fieldName) ~ '[' ~ key ~ ']' }}"
|
2021-08-18 14:12:03 +03:00
|
|
|
placeholder="{{ field.placeholder_value|t }}"
|
2018-08-26 11:49:11 +03:00
|
|
|
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
2021-08-18 14:12:03 +03:00
|
|
|
value={% if text == 'true' %}true{% elseif text == 'false' %}false{% else %}"{{ text|join(', ') }}"{% endif %} />
|
2018-08-16 15:06:18 -07:00
|
|
|
{% endif %}
|
2015-11-27 19:28:19 +01:00
|
|
|
|
2018-08-16 15:06:18 -07:00
|
|
|
<span data-grav-array-action="rem" class="fa fa-minus"></span>
|
|
|
|
|
<span data-grav-array-action="add" class="fa fa-plus"></span>
|
|
|
|
|
</div>
|
2017-05-15 15:08:26 -06:00
|
|
|
{% endif %}
|
2016-02-01 11:27:34 -08:00
|
|
|
{% endmacro %}
|
2015-09-08 09:23:59 +02:00
|
|
|
|
2018-08-26 11:49:11 +03:00
|
|
|
{% import _self as array_field %}
|
|
|
|
|
|
|
|
|
|
{% block global_attributes %}
|
|
|
|
|
data-grav-array-name="{{ (scope ~ field.name)|fieldName }}"
|
2021-08-18 14:12:03 +03:00
|
|
|
data-grav-array-keyname="{{ field.placeholder_key|t }}"
|
|
|
|
|
data-grav-array-valuename="{{ field.placeholder_value|t }}"
|
2018-08-26 11:49:11 +03:00
|
|
|
data-grav-array-textarea="{{ field.value_type == 'textarea' }}"
|
|
|
|
|
{{ parent() }}
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
2016-02-01 11:27:34 -08:00
|
|
|
{% block input %}
|
2018-02-22 16:15:00 -07:00
|
|
|
<div class="{{ field.size }}" data-grav-array-type="container"{% if field.value_only %} data-grav-array-mode="value_only"{% endif %}{{ value|length <= 1 ? ' class="one-child"' : '' }}>
|
2016-02-01 11:27:34 -08:00
|
|
|
{% if value|length %}
|
|
|
|
|
{% for key, text in value -%}
|
|
|
|
|
{% if text is not iterable %}
|
2016-03-15 21:36:14 +02:00
|
|
|
{{ array_field.renderer(key, text, field, scope) }}
|
2016-02-01 11:27:34 -08:00
|
|
|
{% else %}
|
|
|
|
|
{# Backward compatibility for nested arrays (metas) which are not supported anymore #}
|
|
|
|
|
{% for subkey, subtext in text -%}
|
2017-05-15 15:08:26 -06:00
|
|
|
{{ array_field.renderer(key ~ '[' ~ subkey ~ ']', subtext, field, scope) }}
|
2016-02-01 11:27:34 -08:00
|
|
|
{% endfor %}
|
|
|
|
|
{% endif %}
|
2015-06-01 21:22:56 +02:00
|
|
|
{% endfor %}
|
2015-07-28 12:40:11 -07:00
|
|
|
{%- else -%}
|
2016-02-01 11:27:34 -08:00
|
|
|
{# Empty value, mock the entry field#}
|
2015-06-01 21:22:56 +02:00
|
|
|
<div class="form-row" data-grav-array-type="row">
|
2016-08-11 19:17:02 +02:00
|
|
|
<span data-grav-array-action="sort" class="fa fa-bars"></span>
|
|
|
|
|
{% if field.value_only != true %}
|
2018-08-16 15:06:18 -07:00
|
|
|
<input
|
|
|
|
|
data-grav-array-type="key"
|
|
|
|
|
type="text"
|
|
|
|
|
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
2021-08-18 14:12:03 +03:00
|
|
|
placeholder="{{ field.placeholder_key|t }}" />
|
2018-08-16 15:06:18 -07:00
|
|
|
{% endif %}
|
|
|
|
|
{% if field.value_type == 'textarea' %}
|
|
|
|
|
<textarea
|
|
|
|
|
data-grav-array-type="value"
|
|
|
|
|
name="{{ (scope ~ field.name)|fieldName }}"
|
|
|
|
|
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
2021-08-18 14:12:03 +03:00
|
|
|
placeholder="{{ field.placeholder_value|t }}"></textarea>
|
2018-08-16 15:06:18 -07:00
|
|
|
{% else %}
|
|
|
|
|
<input
|
|
|
|
|
data-grav-array-type="value"
|
|
|
|
|
type="text"
|
|
|
|
|
name="{{ (scope ~ field.name)|fieldName }}"
|
|
|
|
|
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
2021-08-18 14:12:03 +03:00
|
|
|
placeholder="{{ field.placeholder_value|t }}" />
|
2016-08-11 19:17:02 +02:00
|
|
|
{% endif %}
|
2015-06-01 21:22:56 +02:00
|
|
|
<span data-grav-array-action="rem" class="fa fa-minus"></span>
|
|
|
|
|
<span data-grav-array-action="add" class="fa fa-plus"></span>
|
|
|
|
|
</div>
|
2015-07-28 12:40:11 -07:00
|
|
|
{%- endif %}
|
2015-06-01 21:22:56 +02:00
|
|
|
</div>
|
|
|
|
|
{% endblock %}
|