-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathforms.py
More file actions
191 lines (162 loc) · 6.37 KB
/
Copy pathforms.py
File metadata and controls
191 lines (162 loc) · 6.37 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# -*- coding: utf-8 -*-
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, PrependedAppendedText, FormActions
class MessageForm(forms.Form):
text_input = forms.CharField()
textarea = forms.CharField(
widget=forms.Textarea(),
)
radio_buttons = forms.ChoiceField(
choices=(
('option_one',
"Option one is this and that be sure to include why it's great"),
('option_two',
"Option two can is something else and selecting it will deselect option one")
),
widget=forms.RadioSelect,
initial='option_two',
)
checkboxes = forms.MultipleChoiceField(
choices=(
('option_one',
"Option one is this and that be sure to include why it's great"),
('option_two',
'Option two can also be checked and included in form results'),
('option_three',
'Option three can yes, you guessed it also be checked and included in form results')
),
initial='option_one',
widget=forms.CheckboxSelectMultiple,
help_text="<strong>Note:</strong> Labels surround all the options for much larger click areas and a more usable form.",
)
appended_text = forms.CharField(
help_text="Here's more help text"
)
appended_text2 = forms.CharField(
help_text="And a bigger appended text field"
)
appended_select = forms.ChoiceField(
label="Select field with appended text",
choices=[(1, "Choice 1"), (2, "Choice 2")],
help_text="Some help text"
)
prepended_appended_select = forms.ChoiceField(
label="Select field with both preprended and appended text",
choices=[(1, "Choice 1"), (2, "Choice 2")],
help_text="Some help text"
)
prepended_select = forms.ChoiceField(
label="Select field with prepended text",
choices=[(1, "Choice 1"), (2, "Choice 2")],
help_text="Some help text"
)
prepended_text = forms.CharField()
prepended_text_two = forms.CharField()
multicolon_select = forms.MultipleChoiceField(
choices=(('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5')),
help_text=(
'This strange option climbing out of the box is in the examples too '
'Only without Flexbox '
'https://v4-alpha.getbootstrap.com/components/forms/#form-controls'),
)
boolean_field = forms.BooleanField()
file_field = forms.FileField()
# Bootstrap4
helper = FormHelper()
helper.layout = Layout(
Field('text_input', css_class='form-control-lg'),
Field('textarea', rows="3", css_class='form-control-lg'),
'radio_buttons',
Field('checkboxes', style="background: #FAFAFA"),
AppendedText('appended_text', '.00'),
AppendedText('appended_text2', '.00', css_class='form-control-lg'),
AppendedText('appended_select', '.00'),
PrependedAppendedText('prepended_appended_select', '$', '.00'),
PrependedText('prepended_select', '$'),
PrependedText('prepended_text',
'<input type="checkbox" checked="checked" value="" id="" name="">',
active=True),
PrependedText('prepended_text_two', '@'),
'multicolon_select',
'boolean_field',
'file_field',
Div(
Div(
Submit('save_changes', 'Save changes', css_class="btn-primary"),
Submit('cancel', 'Cancel'),
),
css_class='form-group'
)
)
class HorizontalMessageForm(forms.Form):
text_input = forms.CharField()
textarea = forms.CharField(
widget=forms.Textarea(),
)
radio_buttons = forms.ChoiceField(
choices=(
('option_one',
"Option one is this and that be sure to include why it's great"),
('option_two',
"Option two can is something else and selecting it will deselect option one")
),
widget=forms.RadioSelect,
initial='option_two',
)
checkboxes = forms.MultipleChoiceField(
choices=(
('option_one',
"Option one is this and that be sure to include why it's great"),
('option_two',
'Option two can also be checked and included in form results'),
('option_three',
'Option three can yes, you guessed it also be checked and included in form results')
),
initial='option_one',
widget=forms.CheckboxSelectMultiple,
help_text="<strong>Note:</strong> Labels surround all the options for much larger click areas and a more usable form.",
)
appended_text = forms.CharField(
help_text="Here's more help text"
)
appended_text2 = forms.CharField(
help_text="And a bigger appended text field"
)
prepended_text = forms.CharField()
prepended_text_two = forms.CharField()
multicolon_select = forms.MultipleChoiceField(
choices=(('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5')),
)
boolean_field = forms.BooleanField()
file_field = forms.FileField()
# Bootstrap4
helper = FormHelper()
helper.layout = Layout(
Field('text_input', css_class='form-control-lg'),
Field('textarea', rows="3", css_class='form-control-lg'),
Field('radio_buttons'),
Field('checkboxes', style="background: #FAFAFA"),
AppendedText('appended_text', '.00'),
AppendedText('appended_text2', '.00', css_class='form-control-lg'),
PrependedText('prepended_text',
'<input type="checkbox" checked="checked" value="" id="" name="">',
active=True),
PrependedText('prepended_text_two', '@'),
Field('multicolon_select'),
Field('boolean_field'),
Field('file_field'),
Div(
Div(
Submit('save_changes', 'Save changes', css_class="btn-primary"),
Submit('cancel', 'Cancel'),
css_class='col-8 ml-auto'
),
css_class='form-group row'
)
)
helper.form_group_wrapper_class = 'row'
helper.form_class = 'form-horizontal'
helper.label_class = 'col-sm-4'
helper.field_class = 'col-sm-8'