Skip to content

Instantly share code, notes, and snippets.

@davidhellmann
Created August 28, 2019 11:16
Show Gist options
  • Save davidhellmann/96d292f543d30082e8d618df737b07e5 to your computer and use it in GitHub Desktop.
Save davidhellmann/96d292f543d30082e8d618df737b07e5 to your computer and use it in GitHub Desktop.
{# @var craft \craft\web\twig\variables\CraftVariable #}
{# @var entry \craft\elements\Entry #}
{#
Description of what this file is for
@package baukasten
@author Sarah Schütz [[email protected]]
o-freeform
------------------------------------------------------------
#}
{# -- Set Defaults -- #}
{% set defaults = {
cn: 'o-freeform',
modifiers: [],
customClasses: [],
data: {},
js: null,
form: null,
} %}
{# -- Merge Default with Options -- #}
{% set opt = opt is defined ? defaults|merge(opt) : defaults %}
{# -- Macros -- #}
{% import '_macros/_macro-settings.twig' as module %}
{# -- Modul -- #}
{% if opt.form %}
<div {{ module.settings(opt) }}>
{{ opt.form.renderTag }}
{# {% if opt.form.pages|length > 1 %}
<ul class="m-freeform-pages">
{% for page in opt.form.pages %}
<li>
{% if opt.form.currentPage.index == page.index %}
<b>{{ page.label }}</b>
{% else %}
{{ page.label }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %} #}
{% for row in opt.form %}
<div class="o-freeform__row">
{% for field in row %}
<div class="o-freeform__col">
{% switch field.type %}
{% case "text" %}
{% include '_modules/freeform/formFields/inputText.twig' with { field: field } only %}
{% case "datetime" %}
{% include '_modules/freeform/formFields/inputDatetime.twig' with { field: field } only %}
{% case "textarea" %}
{% include '_modules/freeform/formFields/textarea.twig' with { field: field } only %}
{% case "email" %}
{% include '_modules/freeform/formFields/inputEmail.twig' with { field: field } only %}
{% case "select" %}
{% include '_modules/freeform/formFields/select.twig' with { field: field } only %}
{% case "multiple_select" %}
{% include '_modules/freeform/formFields/selectMultiple.twig' with { field: field } only %}
{% case "checkbox" %}
{% include '_modules/freeform/formFields/checkbox.twig' with { field: field } only %}
{% case "checkbox_group" %}
{% include '_modules/freeform/formFields/checkboxGroup.twig' with { field: field } only %}
{% case "radio_group" %}
{% include '_modules/freeform/formFields/radioGroup.twig' with { field: field } only %}
{% case "file" %}
{% include '_modules/freeform/formFields/intputFile.twig' with { field: field } only %}
{% case "number" %}
{% include '_modules/freeform/formFields/inputNumber.twig' with { field: field } only %}
{% case "dynamic_recipients" %}
{% include '_modules/freeform/formFields/dynamicRecipients.twig' with { field: field } only %}
{% case "html" %}
{% include '_modules/freeform/formFields/html.twig' with { field: field } only %}
{% case "submit" %}
{% include '_modules/freeform/errors.twig' with { hasErrors: opt.form.hasErrors, errors: opt.form.errors } only %}
{% include '_modules/freeform/formFields/submit.twig' with { field: field } only %}
{% endswitch %}
</div>
{% endfor %}
</div>
{% endfor %}
{{ opt.form.renderClosingTag }}
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment