merge master in prod
This commit is contained in:
@@ -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;">
|
||||
|
||||
Reference in New Issue
Block a user