{# macros to create form fields #} {% macro field(type, name, label="", value=none, class="", control_class="", help="", required=false, icon_left=none, icon_right=none, in_group=false, attrs=none) %} {# generic field "class" keyword can be used to add classes additional kwargs will be passed as attributes #} {% if not in_group %}
{% endif %} {% set cur_id = name|next_gidx %} {% if label %} {% endif %}
{% if icon_left %} {# we use with font from CSS instead of SVG, because using directly SVG doesn't play way with Bulma's control #} {% endif %} {% if icon_right %} {% endif %}
{% if help %}

{{help}}

{% endif %} {% if caller %} {{ caller() }} {% endif %} {% if not in_group %}
{% endif %} {% endmacro %} {% macro select(name, options_list, selected=none, required=false, multiple=false, class="") %} {# selection of elements with {% for value, label in options_list %} {% endfor %} {% endmacro %} {% macro choices(name, choices_list, checked=none, class="") %}
{% for choice, label in choices_list %} {% endfor %}
{% endmacro %} {% macro int(name, label="", init=0, class="", control_class="", placeholder=none, min=none, max=none, step=none, in_group=false) %} {{ 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}) }} {% endmacro %} {% macro checkbox(name, label="", checked=false) %} {% set cur_id = name|next_gidx %} {% endmacro %} {% macro text(name, label="", value=none, class="", control_class="", placeholder=none, required=false, pattern=none, title=none, autocomplete=none, icon_left=none, icon_right=none, in_group=false) %} {{ field("text", name=name, label=label, value=value, class=class, control_class=control_class, 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) }} {% endmacro %} {% macro password(name, label="", value=none, required=false, minlength=none, icon_left=none, icon_right=none) %} {{ field("password", name=name, label=label, value=value, required=required, icon_left=icon_left, icon_right=icon_right, attrs={'minlength': minlength}) }} {% endmacro %} {% macro email(name, label="", required=false, value=none, icon_left=none, icon_right=none) %} {{ field("email", name=name, label=label, value=value, required=required, icon_left=icon_left, icon_right=icon_right) }} {% endmacro %} {% macro date(name, label="", required=false) %} {{ field("date", name=name, label=label, required=required) }} {% endmacro %} {% macro url(name, label="", class="", placeholder=none, required=false, title=none, pattern=none) %} {{ field("url", name=name, label=label, required=required, attrs={'placeholder': placeholder, 'title': title, 'pattern': pattern}) }} {% endmacro %} {% macro file(name, label="", required=false) %} {{ field("file", name=name, label=label, required=required) }} {% endmacro %} {% macro textarea(name, label="", rows=none, cols=50, placeholder="", help="", required=false) %}
{% set cur_id = name|next_gidx %} {% if label %} {% endif %} {% if help %}

{{help}}

{% endif %}
{% endmacro %} {% macro meta(name, value) %} {% endmacro %} {% macro submit(text=_("Send"), id=none, class="", icon=none, attrs=none) %} {# submit button @param text(str): label of the button @param id(none, str): id of the element #}
{{text}} {% if icon %} {% endif %}
{% endmacro %}