Mercurial > libervia-templates
diff sat_templates/templates/default/input/field.html @ 203:bdc578994b97
input/field: added "select" field for <select> inputs + "id" attribute can now be specified for submit button
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 26 May 2019 22:06:10 +0200 |
parents | 178f55b825b7 |
children | aa37750c2617 |
line wrap: on
line diff
--- a/sat_templates/templates/default/input/field.html Sun May 26 22:05:06 2019 +0200 +++ b/sat_templates/templates/default/input/field.html Sun May 26 22:06:10 2019 +0200 @@ -13,6 +13,22 @@ </span> {% endmacro %} +{% macro select(name, options_list, selected=none, required=false, multiple=false) %} + {# selection of elements with <select> + + @param name: name of the field + @param options_list(list[str, str]): list of name, label of options + @param selected(none, list): list of select elements + @param required(bool): true this field is required + @param multiple(bool): true is multiple selection is possible + #} + <select name="{{name}}" class="form_input {{kwargs.pop('class', '')}}" {{"required" if required}}> + {% for value, label in options_list %} + <option value="{{value}}" {{'selected' if selected and value in selected}}>{{label}}</option> + {% endfor %} + </select> +{% endmacro %} + {% macro choices(name, choices_list, checked=none) %} {% for choice, label in choices_list %} <div class="form_input {{kwargs.pop('class', '')}}"> @@ -71,6 +87,11 @@ <input type="hidden" name="{{name}}" value="{{value}}"> {% endmacro %} -{% macro submit(text=_("Send")) %} - <input class="form_submit btn" type="submit" value="{{text}}" class="{{kwargs.pop('class', '')}}"> +{% macro submit(text=_("Send"), id=none) %} + {# submit button + + @param text(str): label of the button + @param id(none, str): id of the element + #} + <input {{ 'id="{id}"'.format(id=id)|safe if id }} class="form_submit btn" type="submit" value="{{text}}" class="{{kwargs.pop('class', '')}}"> {% endmacro %}