merge master in prod

This commit is contained in:
2020-09-08 12:00:45 +02:00
parent b925edaa9e
commit 3e5e731c2c
226 changed files with 8516 additions and 4149 deletions
@@ -2,41 +2,57 @@
{% import _self as self %}
{% for index, field in fields %}
{% set input = attribute(field, "input@") %}
{% if input is null or input == true %}
{% if form.value(scope ~ field.name) %}
{% block field %}
<div>
{% block field_label %}
<strong>{{ field.label|t|e }}</strong>:
{% endblock %}
{% block field_value %}
{% if field.type == 'checkboxes' %}
<ul>
{% set use_keys = field.use is defined and field.use == 'keys' %}
{% for key,value in form.value(scope ~ field.name) %}
{% set index = (use_keys ? key : value) %}
<li>{{ field.options[index]|e }}</li>
{% endfor %}
</ul>
{% elseif field.type == 'checkbox' %}
{{ (form.value(scope ~ field.name) == 1) ? "GRAV.YES"|t|e : "GRAV.NO"|t|e }}
{% elseif field.type == 'select' %}
{{ field.options[form.value(scope ~ field.name)]|e }}
{% else %}
{{ string(form.value(scope ~ field.name))|nl2br }}
{% endif %}
{% endblock %}
</div>
{% endblock %}
{% endif %}
{%- set show_field = attribute(field, "input@") ?? field.store ?? true %}
{% if field.fields %}
{%- set new_scope = field.nest_id ? scope ~ field.name ~ '.' : scope -%}
{{- self.render_field(form, field.fields, new_scope) }}
{% else %}
{% if field.fields %}
{% set new_scope = field.nest_id ? scope ~ field.name ~ '.' : scope %}
{{ self.render_field(form, field.fields, new_scope) }}
{% if show_field %}
{%- set value = form.value(scope ~ (field.name ?? index)) -%}
{% if value %}
{% block field %}
<div>
{% block field_label %}
<strong>{{ field.label|t|e }}</strong>:
{% endblock %}
{% block field_value %}
{% if field.type == 'checkboxes' %}
<ul>
{% set use_keys = field.use is defined and field.use == 'keys' %}
{% for key,value in form.value(scope ~ field.name) %}
{% set index = (use_keys ? key : value) %}
<li>{{ field.options[index]|e }}</li>
{% endfor %}
</ul>
{% elseif field.type == 'checkbox' %}
{{ (form.value(scope ~ field.name) == 1) ? "GRAV.YES"|t|e : "GRAV.NO"|t|e }}
{% elseif field.type == 'select' %}
{{ field.options[form.value(scope ~ field.name)]|e }}
{% else %}
{% set value = form.value(scope ~ field.name) %}
{% if value is iterable %}
<ul>
{% for val in value %}
{% if val is iterable %}
<ul>
{% for v in val %}
<li>{{ string(v)|e }}</li>
{% endfor %}
</ul>
{% else %}
<li>{{ string(val)|e }}</li>
{% endif %}
{% endfor %}
</ul>
{% else %}
{{ string(value)|e|nl2br }}
{% endif %}
{% endif %}
{% endblock %}
</div>
{% endblock %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
@@ -45,4 +61,3 @@
{% import _self as macro %}
{{ macro.render_field(form, form.fields, '') }}
@@ -1,14 +1,16 @@
{%- macro render_field(form, fields, scope) %}
{%- import _self as self %}
{%- for index, field in fields %}
{%- set input = attribute(field, "input@") %}
{%- if input is null or input == true %}
{%- set value = form.value(scope ~ (field.name ?? index)) %}
{{- scope ~ (field.name ?? index) }}: {{ string(value is iterable ? value|json_encode : value|escape('yaml')) ~ "\r\n" }}
{%- else %}
{%- if field.fields %}
{%- set show_field = attribute(field, "input@") ?? field.store ?? true %}
{%- if field.fields %}
{%- set new_scope = field.nest_id ? scope ~ field.name ~ '.' : scope -%}
{{- self.render_field(form, field.fields, new_scope) }}
{%- else %}
{%- if show_field %}
{%- set value = form.value(scope ~ (field.name ?? index)) -%}
{%- if value -%}
{{- field.label }}: {{ string(value is iterable ? value|json_encode : value|e) ~ "\r\n" }}
{%- endif -%}
{%- endif %}
{%- endif %}
{%- endfor %}
@@ -16,4 +18,4 @@
{%- import _self as macro %}
{%- autoescape false %}
{{- macro.render_field(form, form.fields, '') ~ "\r\n" }}
{%- endautoescape %}
{%- endautoescape %}
@@ -1,4 +1,7 @@
{% if not field.validate.ignore %}
{% if not field.validate.ignore %}
{% use 'forms/layouts/field-variables.html.twig' %}
{% block field_override_variables_before %}{% endblock %}
{% set field_name = (scope ~ field.name)|fieldName %}
{% set vertical = field.style == 'vertical' %}
@@ -7,11 +10,11 @@
{% set toggleable = field.toggleable ?? false %}
{% if toggleable %}
{% set originalValue = originalValue is defined ? originalValue : value %}
{% set toggleableChecked = originalValue is not null and originalValue is not empty %}
{% set toggleableChecked = originalValue is not null %}
{% elseif field.overridable %}
{% set toggleable = true %}
{% set default = form.getDefaultValue(field.name) ?? field.default %}
{% set toggleableChecked = value != default %}
{% set toggleableChecked = value is not null and value != default %}
{% endif %}
{% set cookie_name = 'forms-' ~ form.name ~ '-' ~ field.name %}
@@ -27,6 +30,12 @@
{# DEPRECATED: Needed by old form fields; remove when backwards compatibility breaks are allowed #}
{% set isDisabledToggleable = toggleable and not toggleableChecked %}
{% if toggleable %}
{% set form_field_toggleable %}
{% include 'forms/default/toggleable.html.twig' with {checked: toggleableChecked} %}
{% endset %}
{% endif %}
{% set errors = attribute(form.messages, field.name) %}
{% set required = client_side_validation and field.validate.required in ['on', 'true', 1] %}
{% set autofocus = (inline_errors == false) and field.autofocus in ['on', 'true', 1] %}
@@ -35,105 +44,112 @@
{% set autofocus = true %}
{% endif %}
{% block field %}
<div class="form-field {{ form_field_outer_classes }} {{ field.outerclasses }} {% if errors %} has-errors{% endif %} {% block outer_field_classes %}{% endblock %} {% if toggleable %} form-field-toggleable{% endif %}">
{% block contents %}
{% if field.label is not same as(false) and field.display_label is not same as(false) %}
<div class="{{ form_field_outer_label_classes ?: 'form-label' }} {{ field.labelclasses }}">
{% if toggleable %}
{% include 'forms/default/toggleable.html.twig' with {field_name: field_name, field: field, checked: toggleableChecked} %}
{% endif %}
<label class="{{ form_field_label_classes ?: 'inline' }} {{ toggleable ? 'toggleable' }}" {% if field.id is defined %}for="{{ toggleable ? 'toggleable_' ~ field.name : field.id|e }}" {% endif %} >
{% block label %}
{% if field.help %}
{% if field.markdown %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|t|markdown(false)|e }}">{{ field.label|markdown(false)|default(field.name|capitalize)|t }}</span>
{% else %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|t|e }}">{{ field.label|default(field.name|capitalize)|t }}</span>
{% endif %}
{% else %}
{% if field.markdown %}
{{ field.label|markdown(false)|default(field.name|capitalize)|t }}
{% else %}
{{ field.label|default(field.name|capitalize)|t|e('html_attr') }}
{% endif %}
{% endif %}
{% set embed_outer_field_classes %}
{% block outer_field_classes %}{% endblock %}
{% endset %}
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
{% endblock %}
</label>
</div>
{% endif %}
<div class="{{ form_field_outer_data_classes ?: 'form-data' }} {{ field.dataclasses }}"
{% block global_attributes %}
data-grav-field="{{ field.type }}"
data-grav-disabled="{{ toggleable and toggleableChecked }}"
data-grav-default="{{ field.default|json_encode()|e('html_attr') }}"
{% endblock %}
>
{% block group %}
{% block input %}
<div class="{{ form_field_wrapper_classes ?: 'form-input-wrapper' }} {{ field.size }} {{ field.wrapper_classes }}">
{% block prepend %}{% endblock prepend %}
<input
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|join(', ')|e('html_attr') }}"
{# input attribute structures #}
{% block input_attributes %}
class="{{ form_field_input_classes }} {{ field.classes }} {{ field.size }}"
{% if field.id is defined %}id="{{ field.id|e }}" {% endif %}
{% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.placeholder %}placeholder="{{ field.placeholder|t|e('html_attr') }}"{% endif %}
{% if autofocus %}autofocus="autofocus"{% endif %}
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
{% if field.autocomplete is defined %}autocomplete="{{ field.autocomplete }}"{% endif %}
{% if field.autocapitalize in ['off', 'characters', 'words', 'sentences'] %}autocapitalize="{{ field.autocapitalize }}"{% endif %}
{% if field.inputmode in ['none', 'text', 'decimal', 'numeric', 'tel', 'search', 'email', 'url'] %}inputmode="{{ field.inputmode }}"{% endif %}
{% if field.spellcheck in ['true', 'false'] %}spellcheck="{{ field.spellcheck }}"{% endif %}
{# Field Classes #}
{%- if errors %}{% set form_field_outer_core = form_field_outer_core ~ ' has-errors' %}{% endif -%}
{%- if toggleable %}{% set form_field_outer_core = form_field_outer_core ~ ' form-field-toggleable' %}{% endif -%}
{% if field.attributes is defined %}
{% for attribute in field.attributes %}
{{ attribute.name }}="{{ attribute.value|e }}"
{% endfor %}
{% endif %}
{% if required %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern|e }}"{% endif %}
{% if field.validate.message %}title="{{ field.validate.message|t|e }}"
{% elseif field.title is defined %}title="{{ field.title|t|e }}" {% endif %}
{% if field.datasets %}
{% for datakey, datavalue in field.datasets %}
data-{{ datakey }}="{{ datavalue|e('html_attr') }}"
{% endfor %}
{% endif %}
{% endblock %}
/>
{% block append %}{% endblock append %}
{% if inline_errors and errors %}
<div class="{{ form_errors_classes ?: 'form-errors' }}">
<p class="form-message"><i class="fa fa-exclamation-circle"></i> {{ errors|first }}</p>
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}
{% if field.description %}
<div class="form-extra-wrapper {{ field.wrapper_classes }}">
<span class="form-description">
{% if field.markdown %}
{{ field.description|t|markdown(false)|raw }}
{% else %}
{{ field.description|t|raw }}
{% endif %}
</span>
</div>
{% endif %}
{% set layout_form_field_outer_classes = field.outerclasses %}
{% set layout_form_field_outer_classes = layout_form_field_outer_classes|trim ~ ' ' ~ form_field_outer_classes %}
{% set layout_form_field_outer_classes = layout_form_field_outer_classes|trim ~ ' ' ~ embed_outer_field_classes %}
</div>
{% endblock %}
</div>
{# Show Label logic #}
{% set show_label = field.label is not same as(false) and field.display_label is not same as(false )%}
{# Label Classes #}
{% set layout_form_field_outer_label_classes = ((form_field_outer_label_classes ?: 'form-label') ~ ' ' ~ field.labelclasses)|trim %}
{% set layout_form_field_label_classes = (form_field_label_classes ?: 'inline')|trim %}
{% set form_field_label_trim = toggleable ? 'toggleable' %}
{# Field Outer Data classes #}
{% set layout_form_field_outer_data_classes = ((form_field_outer_data_classes ?: ' form-data') ~ ' ' ~ field.dataclasses)|trim %}
{# Field Wrapper classes #}
{% set layout_form_field_wrapper_classes = ((form_field_wrapper_classes ?: ' form-input-wrapper') ~ ' ' ~ field.wrapper_classes)|trim %}
{# Field input classes #}
{% if field|of_type('array') %}
{% if field.classes %}
{% set field = field|merge({'classes': field.classes ~ ' ' ~ block('field_input_classes')|trim }) %}
{% else %}
{% set field = field|merge({'classes': block('field_input_classes') }) %}
{% endif %}
{% endif %}
{% set layout_form_field_input_classes = (form_field_input_classes ~ ' ' ~ field.classes)|trim %}
{# Inline error classes #}
{% set form_field_inline_error_classes = form_field_inline_error_classes ?: ' form-errors' %}
{# Field extra classes #}
{% set form_field_extra_wrapper_classes = 'form-extra-wrapper ' ~ field.wrapper_classes %}
{# Field For #}
{% set form_field_for = toggleable ? 'toggleable_' ~ field.name : field.id|e %}
{# Field Label #}
{% set form_field_label = field.markdown ? field.label|markdown(false) : field.label %}
{% set form_field_label = form_field_label|default(field.name|capitalize)|t %}
{# Field Help #}
{% if field.help %}
{% set form_field_help = field.markdown ? field.help|t|markdown(false)|e : field.help|t|e %}
{% endif %}
{# Field Requied #}
{% set form_field_required = field.validate.required in ['on', 'true', 1] ? true : false %}
{# Field Description #}
{% set form_field_description = field.markdown ? field.description|t|markdown(false)|raw : field.description|t|raw %}
{% extends 'forms/layouts/field.html.twig' %}
{% block global_attributes %}
data-grav-field="{{ field.type }}"
data-grav-disabled="{{ toggleable and toggleableChecked }}"
data-grav-default="{{ field.default|json_encode()|e('html_attr') }}"
{% endblock %}
{% block input_attributes %}
class="{{ layout_form_field_input_classes|trim }} {{ field.size }}"
{% if field.id is defined %}id="{{ field.id|e }}" {% endif %}
{% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.placeholder %}placeholder="{{ field.placeholder|t|e('html_attr') }}"{% endif %}
{% if autofocus %}autofocus="autofocus"{% endif %}
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
{% if field.autocomplete is defined %}autocomplete="{{ field.autocomplete }}"{% endif %}
{% if field.autocapitalize in ['off', 'characters', 'words', 'sentences'] %}autocapitalize="{{ field.autocapitalize }}"{% endif %}
{% if field.inputmode in ['none', 'text', 'decimal', 'numeric', 'tel', 'search', 'email', 'url'] %}inputmode="{{ field.inputmode }}"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
{% if field.spellcheck in ['true', 'false'] %}spellcheck="{{ field.spellcheck }}"{% endif %}
{% if required %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern|e }}"{% endif %}
{% if field.validate.message %}title="{{ field.validate.message|t|e }}"
{% elseif field.title is defined %}title="{{ field.title|t|e }}" {% endif %}
{# Support key/value and .name/.value styles #}
{% if field.attributes is defined %}
{% for key,attribute in field.attributes %}
{% if attribute|of_type('array') %}
{{ attribute.name }}="{{ attribute.value|e('html_attr') }}"
{% else %}
{{ key }}="{{ attribute|e('html_attr') }}"
{% endif %}
{% endfor %}
{% endif %}
{# Support for Custom data attributes#}
{% if field.datasets %}
{% for key, attribute in field.datasets %}
data-{{ key }}="{{ attribute|e('html_attr') }}"
{% endfor %}
{% endif %}
{% endblock %}
{% endif %}
@@ -6,10 +6,10 @@
{% endif %}
{% set value = form ? form.value(field_name) : data.value(field_name) %}
{% block field_open %}{% endblock %}
{% block inner_markup_field_open %}{% endblock %}
{% block field %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endblock %}
{% block field_close %}{% endblock %}
{% block inner_markup_field_close %}{% endblock %}
{% endif %}
{% endfor %}
@@ -4,13 +4,16 @@
{% include 'partials/form-messages.html.twig' %}
{% set scope = scope ?: 'data.' %}
{% set scope = scope ?: form.scope is defined ? form.scope : 'data.' %}
{% set multipart = '' %}
{% set blueprints = blueprints ?? form.blueprint() %}
{% set method = form.method|upper|default('POST') %}
{% set client_side_validation = form.client_side_validation is not null ? form.client_side_validation : config.plugins.form.client_side_validation|default(true) %}
{% set inline_errors = form.inline_errors is not null ? form.inline_errors : config.plugins.form.inline_errors(false) %}
{% set data = data ?? form.data %}
{% set context = context ?? data %}
{% for field in form.fields %}
{% if (method == 'POST' and field.type == 'file') %}
{% set multipart = ' enctype="multipart/form-data"' %}
@@ -18,10 +21,10 @@
{% endfor %}
{% set action = form.action ?: page.route ~ uri.params %}
{% set action = action starts with 'http' ? action : base_url ~ action %}
{% set action = (action starts with 'http') or (action starts with '#') ? action : base_url ~ action %}
{% set action = action|trim('/', 'right') %}
{% if (action == base_url_relative) %}
{% set action = base_url_relative ~ '/' ~ page.slug %}
{% set action = base_url_relative ~ '/' %}
{% endif %}
{% if form.keep_alive %}
@@ -44,88 +47,129 @@
window.GravForm.translations = Object.assign({}, window.GravForm.translations || {}, { PLUGIN_FORM: {} });
", {'group': 'bottom', 'position': 'before'}) %}
<form name="{{ form.name }}"
action="{{ action | trim('/', 'right') }}"
method="{{ method }}"{{ multipart }}
{% if form.id %}id="{{ form.id }}"{% endif %}
{% block form_classes %}
class="{{ form_outer_classes }} {{ form.classes }}"
{% endblock %}
{% if form.novalidate %}novalidate{% endif %}
{% if form.keep_alive %}data-grav-keepalive="true"{% endif %}
>
{# Backwards Compatibility for block overrides #}
{% set override_form_classes %}
{% block form_classes -%}
{{ form_outer_classes }} {{ form.classes }}
{%- endblock %}
{% endset %}
{% set override_inner_markup_fields_start %}
{% block inner_markup_fields_start %}{% endblock %}
{% endset %}
{% set data = data ?? form.data %}
{% set context = context ?? data %}
{% block inner_markup_fields %}
{% for field_name, field in form.fields %}
{% set field_name = field.name ?? field_name %}
{% if field_name and not field.validate.ignore %}
{%- if field_name starts with '.' -%}
{% set field_name = field_name[1:] %}
{% set field = field|merge({ name: field_name }) %}
{% endif %}
{% set value = form ? form.value(field_name) : data.value(field_name) %}
{% block inner_markup_field_open %}{% endblock %}
{% block process_field %}
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" ignore missing %}
{% endblock %}
{% block inner_markup_field_close %}{% endblock %}
{% endif %}
{% endfor %}
{% endblock %}
{% include "forms/fields/formname/formname.html.twig" %}
{% include "forms/fields/formtask/formtask.html.twig" %}
{% set override_inner_markup_fields_end %}
{% block inner_markup_fields_end %}{% endblock %}
{% endset %}
{% set override_inner_markup_fields %}
{% block inner_markup_fields %}
{% for field_name, field in form.fields %}
{% set field_name = field.name ?? field_name %}
{% if field_name and not field.validate.ignore %}
{%- if field_name starts with '.' -%}
{% set field_name = field_name[1:] %}
{% set field = field|merge({ name: field_name }) %}
{% endif %}
{% set value = form ? form.value(field_name) : data.value(field_name) %}
{% block inner_markup_field_open %}{% endblock %}
{% block field %}
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" ignore missing %}
{% endblock %}
{% block inner_markup_field_close %}{% endblock %}
{% endif %}
{% endfor %}
{% endblock %}
{% endset %}
{% set override_inner_markup_buttons_start %}
{% block inner_markup_buttons_start %}
<div class="{{ form_button_outer_classes ?: 'buttons'}}">
{% endblock %}
{% endset %}
{% for button in form.buttons %}
{% if button.outerclasses is defined %}<div class=" {{ button.outerclasses }}">{% endif %}
{% if button.url %}
<a href="{{ button.url starts with 'http' ? button.url : base_url ~ button.url }}">
{% endif %}
<button
{% if button.id %}id="{{ button.id }}"{% endif %}
{% block button_classes %}
class="{{ form_button_classes ?: 'button' }} {{ button.classes }}"
{% endblock %}
{% if button.disabled %}disabled="disabled"{% endif %}
type="{{ button.type|default('submit') }}"
{% if button.task %}
name="task" value="{{ button.task }}"
{% endif %}
>
{% if button.html %}
{{ button.value|t|default('Submit')|raw }}
{% else %}
{{ button.value|t|default('Submit') }}
{% endif %}
</button>
{% if button.url %}
</a>
{% endif %}
{% if button.outerclasses is defined %}</div>{% endif %}
{% endfor %}
{% set override_inner_markup_buttons_end %}
{% block inner_markup_buttons_end %}
</div>
{% endblock %}
{% endset %}
{% include 'forms/fields/uniqueid/uniqueid.html.twig' %}
{# Embed for HTML layout #}
{% embed 'forms/layouts/form.html.twig' %}
{% block embed_form_core %}
name="{{ form.name }}"
action="{{ action }}"
method="{{ method }}"{{ multipart|raw }}
{% if form.id %}id="{{ form.id }}"{% endif %}
{% if form.novalidate %}novalidate{% endif %}
{% if form.keep_alive %}data-grav-keepalive="true"{% endif %}
{% endblock %}
{% block embed_form_classes -%}
class="{{ parent() }} {{ override_form_classes|trim }}"
{%- endblock %}
{% block embed_fields %}
{{ override_inner_markup_fields_start|raw }}
{{ override_inner_markup_fields|raw }}
{% include "forms/fields/formname/formname.html.twig" %}
{% include "forms/fields/formtask/formtask.html.twig" %}
{% include 'forms/fields/uniqueid/uniqueid.html.twig' %}
{{ nonce_field(form.getNonceAction() ?? 'form', form.getNonceName() ?? 'form-nonce')|raw }}
{{ override_inner_markup_fields_end|raw }}
{% endblock %}
{% block embed_buttons %}
{{ override_inner_markup_buttons_start|raw }}
{% for button in form.buttons %}
{% if button.outerclasses is defined %}<div class="{{ button.outerclasses }}">{% endif %}
{% if button.url %}
{% set button_url = button.url starts with 'http' ? button.url : base_url ~ button.url %}
{% endif %}
{% embed 'forms/layouts/button.html.twig' %}
{% block embed_button_core %}
{% if button.id %}id="{{ button.id }}"{% endif %}
{% if button.disabled %}disabled="disabled"{% endif %}
{% if button.name %}
name="{{ button.name }}"
{% else %}
{% if button.task %}name="task" value="{{ button.task }}"{% endif %}
{% endif %}
type="{{ button.type|default('submit') }}"
{% endblock %}
{% block embed_button_classes %}
{% block button_classes %}
class="{{ form_button_classes ?: 'button' }} {{ button.classes }}"
{% endblock %}
{% endblock %}
{% block embed_button_content -%}
{%- set button_value = button.value|t|default('Submit') -%}
{%- if button.html -%}
{{- button_value|trim|raw -}}
{%- else -%}
{{- button_value|trim|e -}}
{%- endif -%}
{%- endblock %}
{% endembed %}
{% if button.outerclasses is defined %}</div>{% endif %}
{% endfor %}
{{ override_inner_markup_buttons_end }}
{% endblock %}
{% endembed %}
{{ nonce_field(form.getNonceAction() ?? 'form', form.getNonceName() ?? 'form-nonce')|raw }}
</form>
{% if config.forms.dropzone.enabled %}
<div id="dropzone-template" style="display:none;">
@@ -3,8 +3,8 @@
{% block field %}
{% set avatar = form.value('avatar') %}
{% if avatar %}
<label><img style="max-width:200px;" src="{{ base_url_simple ~ '/' ~ (avatar|first).path }}" /></label>
<label class="{{ field.classes }}"><img class="{{ field.img_classes }}" style="max-width:200px;" src="{{ base_url_simple ~ '/' ~ (avatar|first).path }}" /></label>
{% else %}
<label><img src="https://www.gravatar.com/avatar/{{ form.value('email')|md5 }}?s=200" /></label>
<label class="{{ field.classes }}"><img class="{{ field.img_classes }}" src="https://www.gravatar.com/avatar/{{ form.value('email')|md5 }}?s=200" /></label>
{% endif %}
{% endblock %}
{% endblock %}
@@ -10,11 +10,11 @@
{% block input %}
{% if not site_key %}
<script>console && console.error('site_key was not defined for form "{{ form.name }}" (Grav Form Plugin)')</script>
<script type="application/javascript">console && console.error('site_key was not defined for form "{{ form.name }}" (Grav Form Plugin)')</script>
{% elseif config.plugins.form.recaptcha.version == 3 %}
{#{% do assets.addJs('https://www.google.com/recaptcha/api.js?render='~site_key) %}#}
<script src='https://www.google.com/recaptcha/api.js?render={{ site_key }}&theme={{ theme }}'></script>
<script>
{% do assets.addJs('https://www.google.com/recaptcha/api.js?render='~site_key~'&theme=' ~ theme) %}
{#<script src='https://www.google.com/recaptcha/api.js?render={{ site_key }}&theme={{ theme }}'></script>#}
<script type="application/javascript">
(document.querySelectorAll('form') || []).forEach(function(form, index) {
var submit = function(event) {
event.preventDefault();
@@ -42,7 +42,7 @@
});
</script>
{% elseif config.plugins.form.recaptcha.version == '2-invisible' %}
<script>
<script type="application/javascript">
function captchaOnloadCallback_{{ formName }}() {
var form = document.querySelector('form#{{ form.id }}');
var submits = form.querySelectorAll('[type="submit"]') || [];
@@ -75,7 +75,7 @@
<script src="https://www.google.com/recaptcha/api.js?onload=captchaOnloadCallback_{{ formName }}&hl={{ grav.language.language }}&theme={{ theme }}"
async defer></script>
{% else %}
<script>
<script type="application/javascript">
var captchaOnloadCallback_{{ formName }} = function captchaOnloadCallback_{{ formName }}() {
grecaptcha.render('g-recaptcha-{{ formName }}', {
'sitekey': "{{ site_key }}",
@@ -4,14 +4,14 @@
{% endblock %}
{% block input %}
{% set id = field.id|default(field.name) ~ '-' ~ key %}
{% set id = field.id|default(field.name)|hyphenize %}
<div class="{{ form_field_wrapper_classes ?: 'form-input-wrapper' }} {{ field.size }} {{ field.wrapper_classes }}">
<input
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|join(', ') }}"
value="{{ field.value ?? '1' }}"
type="checkbox"
{% if value == true %} checked="checked" {% endif %}
{% if value == field.value ?? '1' %} checked="checked" {% endif %}
{# input attribute structures #}
{% block input_attributes %}
@@ -22,6 +22,7 @@
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if required %}required="required"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
{% endblock %}
/>
<label style="display:inline;" class="inline" for="{{ id|e }}">
@@ -15,7 +15,7 @@
{% block input %}
{% for key, text in field.options %}
{% set id = field.id|default(field.name) ~ '-' ~ key %}
{% set id = field.id|default(field.name)|hyphenize ~ '-' ~ key %}
{% set name = field.use == 'keys' ? key : id %}
{% set val = field.use == 'keys' ? '1' : key %}
{% set checked = (field.use == 'keys' ? value[key] : key in value) %}
@@ -4,7 +4,7 @@
<div class="form-input-wrapper {{ field.size }}">
<input
type="text"
value="{{ value|e('html_attr')|join(', ') }}"
value="{{ value|join(', ') }}"
data-key-observe="{{ (scope ~ field.name)|fieldName }}"
{% block input_attributes %}
{% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
@@ -16,6 +16,7 @@
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
{% if field.validate.message %}title="{{ field.validate.message|e|t }}"
@@ -23,4 +24,4 @@
{% endblock %}
/>
</div>
{% endblock %}
{% endblock %}
@@ -1,5 +1,7 @@
{% extends "forms/field.html.twig" %}
{% set value = null %}
{% block input_attributes %}
type="password"
{{ parent() }}
@@ -16,6 +16,7 @@
{% if key == value %}checked="checked" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if required %}required="required"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
/>
<label style="display: inline" class="inline" for="{{ id|e }}">{{ text|t|raw }}</label>
</div>
@@ -17,6 +17,7 @@
{% if required %}required="required"{% endif %}
{% if field.multiple in ['on', 'true', 1] %}multiple="multiple"{% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
{% if field.form %}form="{{ field.form }}"{% endif %}
{% if field.key %}
data-key-observe="{{ (scope ~ field.name)|fieldName }}"
@@ -46,14 +47,15 @@
{{ avalue|raw }}
</option>
{% elseif item_value is iterable %}
<optgroup label="{{ key }}">
{%for subkey, suboption in item_value %}
{% set selected = field.selectize ? suboption : subkey %}
{% set item_value = field.selectize and field.multiple ? suboption : subkey %}
<option {% if subkey == value or (field.multiple and selected in value) %}selected="selected"{% endif %} value="{{ suboption }}">
{{ suboption|t|raw }}
</option>
{% endfor %}
{% set optgroup_label = item_value|keys|first %}
<optgroup label="{{ optgroup_label }}">
{% for subkey, suboption in field.options[key][optgroup_label] %}
{% set selected = field.selectize ? suboption : subkey %}
{% set item_value = field.selectize and field.multiple ? suboption : subkey %}
<option {% if subkey == value or (field.multiple and selected in value) %}selected="selected"{% endif %} value="{{ suboption }}">
{{ suboption|t|raw }}
</option>
{% endfor %}
</optgroup>
{% else %}
{% set selected = field.selectize ? item_value : key %}
@@ -1,42 +1,2 @@
{% extends "forms/field.html.twig" %}
{% block global_attributes %}
data-grav-selectize="{{ (field.selectize is defined ? field.selectize : {})|json_encode()|e('html_attr') }}"
{{ parent() }}
{% endblock %}
{% block input %}
<div class="{{ form_field_wrapper_classes ?: 'form-select-wrapper' }} {{ field.size }} {{ field.wrapper_classes }}">
<select name="{{ (scope ~ field.name)|fieldName ~ (field.multiple ? '[]' : '') }}"
class="{{ form_field_select_classes }} {{ field.classes }}"
{% if field.id is defined %}id="{{ field.id|e }}" {% endif %}
{% if field.style is defined %}style="{{ field.style|e }}" {% endif %}
{% if field.disabled %}disabled="disabled"{% endif %}
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if required %}required="required"{% endif %}
{% if field.multiple in ['on', 'true', 1] %}multiple="multiple"{% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.form %}form="{{ field.form }}"{% endif %}
{% if field.key %}
data-key-observe="{{ (scope ~ field.name)|fieldName }}"
{% endif %}
>
{% if field.placeholder %}<option value="" disabled selected>{{ field.placeholder|t|raw }}</option>{% endif %}
{% for key, optgroup in field.options %}
{% set optgroup_label = optgroup|keys|first %}
<optgroup label="{{ optgroup_label }}">
{%for subkey, suboption in field.options[key][optgroup_label] %}
{% set selected = field.selectize ? suboption : subkey %}
{% set item_value = field.selectize and field.multiple ? suboption : subkey %}
<option {% if subkey == value or (field.multiple and selected in value) %}selected="selected"{% endif %} value="{{ suboption }}">
{{ suboption|t|raw }}
</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
</div>
{% endblock %}
{# Deprecated Form 4.0: Just use `select` field #}
{% extends "forms/fields/select/select.html.twig" %}
@@ -15,11 +15,11 @@
{% set tabs = tabs|merge([tab]) %}
{% endif %}
{% endfor %}
{% set count = tabs|count %}
{% set count = tabs|length %}
{% if count == 0 %}
{# Nothing to display #}
{% elseif count == 1 %}
{% elseif count == 1 and not admin %}
{% for field in (tabs|first).fields %}
{% if field.type %}
{% set value = field.name ? (form ? form.value(field.name) : data.value(field.name)) : data.toArray %}
@@ -52,10 +52,10 @@
</div>
<div class="tabs-content">
{% embed 'forms/default/fields.html.twig' with {name: field.name, fields: field.fields} %}
{% block field_open %}
{% block inner_markup_field_open %}
<div id="tab-{{ tabsKey ~ loop.index }}" class="tab__content {{ (storedTab == scope ~ field.name) or active == loop.index ? 'active' : '' }}">
{% endblock %}
{% block field_close %}
{% block inner_markup_field_close %}
</div>
{% endblock %}
{% endembed %}
@@ -1,3 +1,7 @@
{% if field.prepend or field.append or field.copy_to_clipboard %}
{% set field = field|merge({'wrapper_classes': 'form-input-addon-wrapper'}) %}
{% endif %}
{% extends "forms/field.html.twig" %}
{% block prepend %}
@@ -19,7 +23,6 @@
{% block append %}
{% if field.copy_to_clipboard %}
<div class="form-input-addon form-input-append copy-to-clipboard">
{{ dump(field.copy_to_clipboard|t|raw) }}
{% if field.copy_to_clipboard in ['0', '1'] %}
<i class="fa fa-clipboard"></i>
{% else %}
@@ -33,9 +36,4 @@
{% endif %}
{% endblock %}
{% block input %}
{% if field.prepend or field.append or field.copy_to_clipboard %}
{% set field = field|merge({'wrapper_classes': 'form-input-addon-wrapper'}) %}
{% endif %}
{{ parent() }}
{% endblock %}
@@ -17,6 +17,7 @@
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
{% if required %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
{% if field.validate.message %}title="{{ field.validate.message|t|e }}"{% endif %}
@@ -7,9 +7,6 @@
{% import _self as macro %}
{% set value = value ?? field.default %}
{% set value = (value is same as(false) ? 0 : value) %}
{% set has_hidden = false %}
{% for key, text in field.options %}
{% if key is empty %}
@@ -23,6 +20,12 @@
{% endblock %}
{% block input %}
{% set value = (value is same as(false) ? 0 : value) %}
{% if field.force_bool and get_type(value) == 'string'%}
{% set value = true %}
{% endif %}
<div class="switch-toggle switch-grav {{ field.size }} switch-{{ field.options|length }} {{ field.classes }}">
{% set maxLen = 0 %}
@@ -55,6 +58,7 @@
{% endif %}
{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
/>
<label for="{{ id }}">{{ (macro.spanToggle(translation, maxLen)|trim)|raw }}</label>
{% endfor %}
@@ -1 +1 @@
<a href="{{ url(value) }}" target="_blank"><i class="fa fa-link"></i>{{ value|e }}</a>
<a href="{{ url(value) }}" target="_blank"><i class="fa fa-link"></i> {{ value|e }}</a>
@@ -0,0 +1,12 @@
{% set button_tag %}
<button
{% block embed_button_core %}{% endblock %}
{% block embed_button_classes %}{% endblock %}
>{%- block embed_button_content -%}{%- endblock -%}</button>
{% endset %}
{% if button_url %}
<a href="{{ button_url|e }}">{{ button_tag|trim|raw }}</a>
{% else %}
{{ button_tag|trim|raw }}
{% endif %}
@@ -0,0 +1 @@
{% block field_input_classes %}{% endblock %}
@@ -0,0 +1,52 @@
{% block field %}
<div class="form-field {{ layout_form_field_outer_classes|trim -}} {{- form_field_outer_core|trim -}}">
{% block contents %}
{% if show_label %}
<div class="{{- layout_form_field_outer_label_classes -}}">
{{- form_field_toggleable -}}
<label class="{{ layout_form_field_label_classes }}{{ form_field_label_trim }}" {% if field.id %}for="{{ form_field_for }}"{% endif %}>
{%- block label -%}
{%- if form_field_help -%}
<span class="tooltip" data-tooltip="{{ form_field_help|e }}">{{ form_field_label|raw }}</span>
{%- else -%}
{{ form_field_label|raw }}
{%- endif -%}
{%- if form_field_required %}
<span class="required">*</span>
{%- endif -%}
{%- endblock -%}
</label>
</div>
{% endif %}
<div class="{{ layout_form_field_outer_data_classes }}"
{% block global_attributes %}{% endblock %}
>
{% block group %}
{% block input %}
<div class="{{ layout_form_field_wrapper_classes }} {{ field.size }}">
{% block prepend %}{% endblock prepend %}
<input
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|join(', ')|e }}"
{% block input_attributes %}{% endblock %}
/>
{% block append %}{% endblock append %}
{% if inline_errors and errors %}
<div class="{{ form_field_inline_error_classes }}">
<p class="form-message"><i class="fa fa-exclamation-circle"></i> {{ errors|first|raw }}</p>
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}
{% if field.description is defined %}
<div class="{{ form_field_extra_wrapper_classes }}">
<span class="form-description">
{{ form_field_description|raw }}
</span>
</div>
{% endif %}
</div>
{% endblock %}
</div>
{% endblock %}
@@ -0,0 +1,7 @@
<form
{% block embed_form_core %}{% endblock %}
{% block embed_form_classes %}{% endblock %}
>
{% block embed_fields %}{% endblock %}
{% block embed_buttons %}{% endblock %}
</form>