annotate sat_templates/templates/default/input/field.html @ 165:9e8d9d754337

base/base.html: don't show menu if main_menu is defined but none or empty
author Goffi <goffi@goffi.org>
date Fri, 14 Sep 2018 19:49:15 +0200
parents e9f0a4215e46
children 178f55b825b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
1 {# macros to create form fields #}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
2
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
3 {% macro field(type, name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
4 {# generic field
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
5 "class" keyword can be used to add classes
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
6 additional kwargs will be passed as attributes #}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
7 <span class="form_input {{kwargs.pop('class', '')}}">
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
8 {% set cur_id = name|next_gidx %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
9 {% if label %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
10 <label for="{{cur_id}}" {{'class="required"'|safe if required}}>{{label}}</label>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
11 {% endif %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
12 <input id="{{cur_id}}" type="{{type}}" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
13 </span>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
14 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
15
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
16 {% macro choices(name, choices_list, checked=none) %}
20
8fa2fd2e928e default: added i18n support
Goffi <goffi@goffi.org>
parents: 18
diff changeset
17 {% for choice, label in choices_list %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
18 <div class="form_input {{kwargs.pop('class', '')}}">
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
19 <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{name|cur_gidx}}">{{label}}</label>
18
d4a8afa7b590 input/field: <label> is separated from <input>
Goffi <goffi@goffi.org>
parents: 10
diff changeset
20 </div>
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
21 {% endfor %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
22 {% endmacro %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
23
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
24 {% macro int(name, label="", init=0) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
25 {{ field("number", name=name, label=label, value=init, step=1, min=0, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
26 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
27
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
28 {% macro checkbox(name, label="", checked=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
29 {% if checked %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
30 {{ field("checkbox", name=name, label=label, checked="checked", **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
31 {% else %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
32 {{ field("checkbox", name=name, label=label, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
33 {% endif %}
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
34 {% endmacro %}
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
35
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
36 {% macro text(name, label="", placeholder="", required=false) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
37 {{ field("text", name=name, label=label, required=required, placeholder=placeholder, **kwargs) }}
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
38 {% endmacro %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
39
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
40 {% macro password(name, label="", required=false) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
41 {{ field("password", name=name, label=label, required=required, **kwargs) }}
52
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
42 {% endmacro %}
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
43
87680eed9e25 input(field, form): improved classes + new email field
Goffi <goffi@goffi.org>
parents: 46
diff changeset
44 {% macro email(name, label="", required=false) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
45 {{ field("email", name=name, label=label, required=required, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
46 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
47
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
48 {% macro date(name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
49 {{ field("date", name=name, label=label, required=required, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
50 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
51
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
52 {% macro url(name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
53 {{ field("url", name=name, label=label, required=required, **kwargs) }}
27
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
54 {% endmacro %}
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
55
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
56 {% macro file(name, label="", required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
57 {{ field("file", name=name, label=label, required=required, **kwargs) }}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
58 {% endmacro %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
59
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
60 {% macro textarea(name, label="", rows=10, cols=50, placeholder='', required=false) %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
61 <div class="form_input {{kwargs.pop('class', '')}}">
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
62 {% set cur_id = name|next_gidx %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
63 {% if label %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
64 <label for="{{cur_id}}" {{'class="required"'|safe if required}}>{{label}}</label>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
65 {% endif %}
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
66 <textarea id="{{cur_id}}" name="{{name}}" rows="{{rows}}" cols="{{cols}}" placeholder="{{placeholder}}" {{"required" if required}} class="{{kwargs.pop('class', '')}}"></textarea>
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
67 </div>
27
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
68 {% endmacro %}
38328c57f3ef field: added new text and textarea macros
Goffi <goffi@goffi.org>
parents: 20
diff changeset
69
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
70 {% macro meta(name, value) %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
71 <input type="hidden" name="{{name}}" value="{{value}}">
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
72 {% endmacro %}
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
73
46
0520b7c9dcc0 input/field: text can be specified for submit button
Goffi <goffi@goffi.org>
parents: 27
diff changeset
74 {% macro submit(text=_("Send")) %}
153
b84d20af0ed3 macros (field, form, textbox): general improvments:
Goffi <goffi@goffi.org>
parents: 147
diff changeset
75 <input class="form_submit button" type="submit" value="{{text}}" class="{{kwargs.pop('class', '')}}">
10
8b5615a1bf3d articles, input: use new embedding mechanism in articles + new macros to build forms and inputs
Goffi <goffi@goffi.org>
parents:
diff changeset
76 {% endmacro %}