Mercurial > libervia-templates
changeset 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 | 102356338118 |
children | dfef430a26ef |
files | default/input/field.html default/input/form.html |
diffstat | 2 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/default/input/field.html Fri Oct 27 18:52:34 2017 +0200 +++ b/default/input/field.html Fri Oct 27 18:54:01 2017 +0200 @@ -1,20 +1,38 @@ {% macro choices(name, choices_list, checked=none) %} {% for choice, label in choices_list %} <div class="form_input"> - <input id="{{'field'|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{'field'|cur_gidx}}">{{label}}</label> + <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{name|cur_gidx}}">{{label}}</label> </div> {% endfor %} {% endmacro %} {% macro int(name, label="", init=0) %} <span class="form_input"> - <label id="{{'field'|next_gidx}}">{{label}}</label><input id="{{'field'|cur_gidx}}" type="number" name="{{name}}" value="{{init}}" step="1" min="0"></label> + <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="number" name="{{name}}" value="{{init}}" step="1" min="0"> + </span> +{% endmacro %} + +{% macro text(name, label="", placeholder="", required=false) %} + {# single line text field + additional kwargs will be passed as attributes #} + <span class="form_input"> + <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="text" name="{{name}}" placeholder="{{placeholder}}" {{"required" if required}} {{kwargs|xmlattr}}> </span> {% endmacro %} -{% macro text(name, label="", placeholder="") %} +{% macro password(name, label="", required=false) %} + {# password field + additional kwargs will be passed as attributes #} <span class="form_input"> - <label id="{{'field'|next_gidx}}">{{label}}</label><input id="{{'field'|cur_gidx}}" type="text" name="{{name}}" placeholder="{{placeholder}}"></label> + <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="password" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}> + </span> +{% endmacro %} + +{% macro email(name, label="", required=false) %} + {# email field + additional kwargs will be passed as attributes #} + <span class="form_input"> + <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="email" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}> </span> {% endmacro %}
--- a/default/input/form.html Fri Oct 27 18:52:34 2017 +0200 +++ b/default/input/form.html Fri Oct 27 18:54:01 2017 +0200 @@ -1,5 +1,5 @@ -{% macro form(action='') %} -<form method="post" action="{{action}}"> +{% macro form(action='', class='') %} +<form method="post" action="{{action}}" {{ {'class': class}|xmlattr }}> {% if csrf_token is defined %} <input type="hidden" name="csrf_token" value="{{csrf_token}}"> {% endif %}