File: widgets-reference.rst

package info (click to toggle)
django-floppyforms 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,740 kB
  • ctags: 1,008
  • sloc: python: 4,477; makefile: 120
file content (351 lines) | stat: -rw-r--r-- 7,535 bytes parent folder | download
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
Widgets reference
=================

For each widgets, the default class attributes.

.. module:: floppyforms.widgets
   :synopsis: FloppyForm's form widgets

.. class:: Input

    .. attribute:: Input.datalist

        A list of possible values, which will be rendered as a ``<datalist>``
        element tied to the input. Note that the list of options passed as
        ``datalist`` elements are only **suggestions** and are not related to
        form validation.

    .. attribute:: Input.template_name

       A path to a template that should be used to render this widget. You can
       change the template name per instance by passing in a keyword argument
       called ``template_name``. This will override the default that is set by
       the widget class. You can also change the template used for rendering by
       an argument to the ``Input.render()`` method. See more about exchanging
       the templates in the :doc:`documentation about customization <customization>`.

.. class:: TextInput

    .. attribute:: TextInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: TextInput.input_type

        ``text``

.. class:: PasswordInput

    .. attribute:: PasswordInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: PasswordInput.input_type

        ``password``

.. class:: HiddenInput

    .. attribute:: HiddenInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: HiddenInput.input_type

        ``hidden``

.. class:: SlugInput

    .. attribute:: SlugInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: SlugInput.input_type

        ``text``

    An text input that renders as ``<input pattern="[-\w]+" ...>`` for
    client-side validation of the slug.

.. class:: IPAddressInput

    .. attribute:: IPAddressInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: IPAddressInput.input_type

        ``text``

    An text input that renders as ``<input pattern="..." ...>`` for
    client-side validation. The pattern checks that the entered value is a
    valid IPv4 address.

.. class:: FileInput

    .. attribute:: FileInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: FileInput.input_type

        ``file``

.. class:: ClearableFileInput

    .. attribute:: ClearableFileInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: ClearableFileInput.input_type

        ``file``

    .. attribute:: ClearableFileInput.initial_text

        ``_('Currently')``

    .. attribute:: ClearableFileInput.input_text

        ``_('Change')``

    .. attribute:: ClearableFileInput.clear_checkbox_label

        ``_('Clear')``

    The ``initial_text``, ``input_text`` and ``clear_checkbox_label``
    attributes are provided in the template context.

.. class:: EmailInput

    .. attribute:: EmailInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: EmailInput.input_type

        ``email``

.. class:: URLInput

    .. attribute:: URLInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: URLInput.input_type

        ``url``

.. class:: SearchInput

    .. attribute:: SearchInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: SearchInput.input_type

        ``search``

.. class:: ColorInput

    .. attribute:: ColorInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: ColorInput.input_type

        ``color``

.. class:: PhoneNumberInput

    .. attribute:: PhoneNumberInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: PhoneNumberInput.input_type

        ``tel``

.. class:: DateInput

    .. attribute:: DateInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: DateInput.input_type

        ``date``

.. class:: DateTimeInput

    .. attribute:: DateTimeInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: DateTimeInput.input_type

        ``datetime``

.. class:: TimeInput

    .. attribute:: TimeInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: TimeInput.input_type

        ``time``

.. class:: NumberInput

    .. attribute:: NumberInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: NumberInput.input_type

        ``number``

    .. attribute:: NumberInput.min

        None

    .. attribute:: NumberInput.max

        None

    .. attribute:: NumberInput.step

        None

    ``min``, ``max`` and ``step`` are available in the ``attrs`` template
    variable if they are not None.

.. class:: RangeInput

    .. attribute:: NumberInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: RangeInput.input_type

        ``range``

    .. attribute:: RangeInput.min

        None

    .. attribute:: RangeInput.max

        None

    .. attribute:: RangeInput.step

        None

    ``min``, ``max`` and ``step`` are available in the ``attrs`` template
    variable if they are not None.

.. class:: Textarea

    .. attribute:: Textarea.template_name

        ``'floppyforms/textarea.html'``

    .. attribute:: Textarea.rows

        10

    .. attribute:: Textarea.cols

        40

    ``rows`` and ``cols`` are available in the ``attrs`` variable.

.. class:: CheckboxInput

    .. attribute:: CheckboxInput.template_name

        ``'floppyforms/input.html'``

    .. attribute:: CheckboxInput.input_type

        ``checkbox``

.. class:: Select

    .. attribute:: Select.template_name

        ``'floppyforms/select.html'``

.. class:: NullBooleanSelect

    .. attribute:: NullBooleanSelect.template_name

        ``'floppyforms/select.html'``

.. class:: RadioSelect

    .. attribute:: RadioSelect.template_name

        ``'floppyforms/radio.html'``

.. class:: SelectMultiple

    .. attribute:: SelectMultiple.template_name

        ``'floppyforms/select_multiple.html'``

.. class:: CheckboxSelectMultiple

    .. attribute:: CheckboxSelectMultiple.template_name

        ``'floppyforms/checkbox_select.html'``

.. class:: MultiWidget

   The same as ``django.forms.widgets.MultiWidget``. The rendering can be
   customized by overriding ``format_output``, which joins all the rendered
   widgets.

.. class:: SplitDateTimeWidget

    Displays a ``DateInput`` and a ``TimeInput`` side by side.

.. class:: MultipleHiddenInput

    A multiple <input type="hidden"> for fields that have several values.

.. class:: SelectDateWidget

    A widget that displays three ``<select>`` boxes, for the year, the month
    and the date.

    Available context:

    * ``year_field``: the name for the year's ``<select>`` box.
    * ``month_field``: the name for the month's ``<select>`` box.
    * ``day_field``: the name for the day's ``<select>`` box.

    .. attribute:: SelectDateWidget.template_name

        The template used to render the widget. Default:
        ``'floppyforms/select_date.html'``.

    .. attribute:: SelectDateWidget.none_value

        A tuple representing the value to display when there is no initial
        value. Default: ``(0, '---')``.

    .. attribute:: SelectDateWidget.day_field

        The way the day field's name is derived from the widget's name.
        Default: ``'%s_day'``.

    .. attribute:: SelectDateWidget.month_field

        The way the month field's name is derived. Default: ``'%s_month'``.

    .. attribute:: SelectDateWidget.year_field

        The way the year field's name is derived. Default: ``'%s_year'``.