-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_form.html
More file actions
107 lines (96 loc) · 5.25 KB
/
user_form.html
File metadata and controls
107 lines (96 loc) · 5.25 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{% load actionkit_tags switchcase %}
{% filter remove_blank_lines %}
{% comment %}
This form template conditionally displays fields based on:
1. Whether the user has a phone number ({% if user.phone %})
2. Whether the user has opted in to SMS ({% if user.custom_fields.sms_opt_in == "Y" %})
Three different scenarios:
1. Users with phone + opt-in: Only show email & zip (and name if needed)
2. Users with phone but no opt-in: Show email, zip, name, and opt-in checkbox
3. Users with no phone: Show email, zip, name, phone field, and opt-in checkbox
To change which fields show, edit {% hide_by_default %} below and set
individual pages' required fields in the page admin, or activate the
User Fields customization option in the page admin to override which
fields are visible and the order they're shown in.
{% endcomment %}
{% field_order name email prefix first_name middle_name last_name suffix country address1 address2 city state zip region postal phone %}
{% hide_by_default prefix first_name middle_name last_name suffix country address1 address2 city state region postal %}
{% for field in user_fields %}
{% switch field.field_name %}
{% case 'zip' %}
{% case 'user_sms_opt_in' %}
{% if not user.custom_fields.sms_opt_in == "Y" %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{{ field.input_html }}
</div>
{% endif %}
{% case 'postal' %}
{% if not user.postal %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{{ field.input_html }}
</div>
{% endif %}
{% case 'email' %}
{% if not user.email %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{{ field.input_html }}
</div>
{% endif %}
{% case 'mobile_phone' %}
{% if not user.phones.mobile %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{{ field.input_html }}
</div>
{% endif %}
{% case 'country' %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{% include "./country_select.html" %}
</div>
{% case 'state' %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{% include "./state_select.html" %}
</div>
{% else %}
<div id="ak-fieldbox-{{ field.field_name }}" {% if field.field_name|is_in:context.required %}class="required"{% endif %}>
<label for="id_{{ field.field_name }}">
{{ field.label_text }}{% if field.field_name|is_in:context.required %}<span class="ak-required-flag">*</span>{% endif %}
</label>
{{ field.input_html }}
</div>
{% endswitch %}
{% endfor %}
{% if 'country'|is_in:fields %}
<input type="hidden" name="auto_country" value="1">
<style type="text/css">
/* Ensure that, if there's no JavaScript, and there are both
* global-friendly and US-only fields, the global-friendly
* fields show rather than the US-only ones */
{% if 'postal'|is_in:fields %}
#ak-fieldbox-zip { display: none; }
{% endif %}
{% if 'region'|is_in:fields %}
#ak-fieldbox-state { display: none; }
{% endif %}
</style>
{% else %}
<input type="hidden" name="country" value="United States">
{% endif %}
{% endfilter %}