comparison sat_templates/templates/bulma/input/field.html @ 349:2e548a9830c6

(bulma) input/field: fix `name` attribute + add `required` to checkbox
author Goffi <goffi@goffi.org>
date Tue, 30 Nov 2021 17:25:35 +0100
parents ae903ca0ed66
children 1de6a0ecd529
comparison
equal deleted inserted replaced
348:789ebf39b2d8 349:2e548a9830c6
65 65
66 {% macro int(name, label="", init=0, class="", control_class="", placeholder=none, min=none, max=none, step=none, in_group=false) %} 66 {% macro int(name, label="", init=0, class="", control_class="", placeholder=none, min=none, max=none, step=none, in_group=false) %}
67 {{ field("number", name=name, label=label, value=init, class=class, control_class=control_class, in_group=in_group, attrs={"min": min, "max": max, "step": step, "placeholder": placeholder}) }} 67 {{ field("number", name=name, label=label, value=init, class=class, control_class=control_class, in_group=in_group, attrs={"min": min, "max": max, "step": step, "placeholder": placeholder}) }}
68 {% endmacro %} 68 {% endmacro %}
69 69
70 {% macro checkbox(name, label="", checked=false) %} 70 {% macro checkbox(name, label="", checked=false, required=false) %}
71 {% set cur_id = name|next_gidx %} 71 {% set cur_id = name|next_gidx %}
72 <label for="{{cur_id}}" class="label checkbox">{{label}}</label> 72 <label for="{{cur_id}}" class="label checkbox">{{label}}</label>
73 <input id="{{cur_id}}" type="checkbox" {% if checked %}checked=checked{% endif %}> 73 <input {{ {"id": cur_id, "name": name}|xmlattr }} type="checkbox" {% if checked %}checked=checked{% endif %} {{"required" if required}}>
74 {% endmacro %} 74 {% endmacro %}
75 75
76 {% macro text(name, label="", value=none, class="", control_class="", placeholder=none, help="", required=false, pattern=none, title=none, autocomplete=none, icon_left=none, icon_right=none, in_group=false) %} 76 {% macro text(name, label="", value=none, class="", control_class="", placeholder=none, help="", required=false, pattern=none, title=none, autocomplete=none, icon_left=none, icon_right=none, in_group=false) %}
77 {{ field("text", name=name, label=label, value=value, class=class, control_class=control_class, help=help, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'placeholder': placeholder, 'pattern': pattern, 'title': title, 'autocomplete': autocomplete}, in_group=in_group, caller=caller) }} 77 {{ field("text", name=name, label=label, value=value, class=class, control_class=control_class, help=help, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'placeholder': placeholder, 'pattern': pattern, 'title': title, 'autocomplete': autocomplete}, in_group=in_group, caller=caller) }}
78 {% endmacro %} 78 {% endmacro %}