comparison default/input/field.html @ 52:87680eed9e25

input(field, form): improved classes + new email field
author Goffi <goffi@goffi.org>
date Fri, 27 Oct 2017 18:54:01 +0200
parents 0520b7c9dcc0
children f76ec90e0e1e
comparison
equal deleted inserted replaced
51:102356338118 52:87680eed9e25
1 {% macro choices(name, choices_list, checked=none) %} 1 {% macro choices(name, choices_list, checked=none) %}
2 {% for choice, label in choices_list %} 2 {% for choice, label in choices_list %}
3 <div class="form_input"> 3 <div class="form_input">
4 <input id="{{'field'|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{'field'|cur_gidx}}">{{label}}</label> 4 <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{name|cur_gidx}}">{{label}}</label>
5 </div> 5 </div>
6 {% endfor %} 6 {% endfor %}
7 {% endmacro %} 7 {% endmacro %}
8 8
9 {% macro int(name, label="", init=0) %} 9 {% macro int(name, label="", init=0) %}
10 <span class="form_input"> 10 <span class="form_input">
11 <label id="{{'field'|next_gidx}}">{{label}}</label><input id="{{'field'|cur_gidx}}" type="number" name="{{name}}" value="{{init}}" step="1" min="0"></label> 11 <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="number" name="{{name}}" value="{{init}}" step="1" min="0">
12 </span> 12 </span>
13 {% endmacro %} 13 {% endmacro %}
14 14
15 {% macro text(name, label="", placeholder="") %} 15 {% macro text(name, label="", placeholder="", required=false) %}
16 {# single line text field
17 additional kwargs will be passed as attributes #}
16 <span class="form_input"> 18 <span class="form_input">
17 <label id="{{'field'|next_gidx}}">{{label}}</label><input id="{{'field'|cur_gidx}}" type="text" name="{{name}}" placeholder="{{placeholder}}"></label> 19 <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="text" name="{{name}}" placeholder="{{placeholder}}" {{"required" if required}} {{kwargs|xmlattr}}>
20 </span>
21 {% endmacro %}
22
23 {% macro password(name, label="", required=false) %}
24 {# password field
25 additional kwargs will be passed as attributes #}
26 <span class="form_input">
27 <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="password" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}>
28 </span>
29 {% endmacro %}
30
31 {% macro email(name, label="", required=false) %}
32 {# email field
33 additional kwargs will be passed as attributes #}
34 <span class="form_input">
35 <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="email" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}>
18 </span> 36 </span>
19 {% endmacro %} 37 {% endmacro %}
20 38
21 {% macro textarea(name, rows=10, cols=50, placeholder='') %} 39 {% macro textarea(name, rows=10, cols=50, placeholder='') %}
22 <textarea name="{{name}}" rows="{{rows}}" cols="{{cols}}" placeholder="{{placeholder}}"></textarea> 40 <textarea name="{{name}}" rows="{{rows}}" cols="{{cols}}" placeholder="{{placeholder}}"></textarea>