forked from jimmylorunning/FormBuilder-2-Craft-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsampleForm.twig
executable file
·52 lines (45 loc) · 2.43 KB
/
sampleForm.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{% extends "_layout" %}
{% set form = craft.formBuilder2.getFormByHandle('contactForm') %}
{% set formSettings = form.formSettings %}
{% set spamProtectionSettings = form.spamProtectionSettings %}
{% set tabs = form.fieldLayout.getFieldLayout().getTabs() %}
{% set scripts = craft.formBuilder2.includeScripts(form) %}
{% block content %}
<form method="post" accept-charset="utf-8" name="{{ form.handle }}" class="formbuilder2" id="{{ form.handle }}"{% if formSettings.hasFileUploads == '1' %} enctype="multipart/form-data"{% endif %}>
<input type="hidden" name="action" value="formBuilder2/entry/submitEntry">
<input type="hidden" name="redirect" data-custom-redirect="{{ formSettings.formRedirect.customRedirect }}" value="{{ formSettings.formRedirect.customRedirectUrl }}">
<input type="hidden" name="formHandle" value="{{ form.handle }}">
{% if spamProtectionSettings.spamTimeMethod == '1' %}<input type="hidden" name="spamTimeMethod" value="{{ 'now'|date('U') }}">{% endif %}
{% if spamProtectionSettings.spamHoneypotMethod == '1' %}<div style="display:none;"><label for="email-addresss-new">{{ spamProtectionSettings.spamHoneypotMethodMessage }}</label><input name="email-address-new" value="" id="email-addresss-new"></div>{% endif %}
{{ getCsrfInput() }}
{# Fields #}
{% for tab in tabs %}
{% set fields = tab.getFields() %}
<fieldset class="{{ tab.name | camelCase(tab.name) }}">
<legend>{{ tab.name }}</legend>
{% for field in fields %}
{% set value = value is defined ? value : [] %}
{% set input = craft.formBuilder2.getInputHtml(field, value) %}
{{ input |raw }}
{% endfor %}
</fieldset>
{% endfor %}
{% if form.extra['termsAndConditions'] is defined and form.extra['termsAndConditions'] %}
{{ craft.formBuilder2.getTermsInputs(form) |raw }}
{% endif %}
{# Errors/Success Messages #}
<div class="notifications">
<p class="notification error-message">{{ craft.session.getFlash('error') | raw }}</p>
<p class="notification success-message">{{ craft.session.getFlash('success') | raw }}</p>
{% set errors = (errors is defined ? errors : null) %}
{% if errors %}
<ul class="errors">
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<button type="submit">{% if formSettings.submitButtonText %}{{ formSettings.submitButtonText }}{% else %}Submit Message{% endif %}</button>
</form>
{% endblock %}