diff sat_templates/templates/bulma/input/field.html @ 304:cdf88211b86b

bulma (input/field): `field` macro now has `control_class` and `in_group` attributes: - `control_class` is used to specify additional classes for the control (when `class` is used for classes of the of the `field`) - when `in_group` is `true`, `field` is not added, only the `control` is used. This is useful for grouping elements in the same field
author Goffi <goffi@goffi.org>
date Sat, 27 Feb 2021 20:44:01 +0100
parents fbea1b9a558f
children 552daa830d42
line wrap: on
line diff
--- a/sat_templates/templates/bulma/input/field.html	Sat Feb 20 13:39:11 2021 +0100
+++ b/sat_templates/templates/bulma/input/field.html	Sat Feb 27 20:44:01 2021 +0100
@@ -1,16 +1,18 @@
 {# macros to create form fields #}
 
-{% macro field(type, name, label="", value=none, class='', help="", required=false, icon_left=none, icon_right=none, attrs=none) %}
+{% 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 #}
 
-    <div class="field form_input {{class}}">
+    {% if not in_group %}
+        <div class="field form_input {{class}}">
+    {% endif %}
         {% set cur_id = name|next_gidx %}
         {% if label %}
             <label for="{{cur_id}}" class="label">{{label}}</label>
         {% endif %}
-        <div class="control{% if icon_left %} has-icons-left{% endif %}{% if icon_right %} has-icons-right{% endif %}">
+        <div class="control{% if icon_left %} has-icons-left{% endif %}{% if icon_right %} has-icons-right{% endif %} {{control_class}}">
             <input id="{{cur_id}}" class="input" type="{{type}}" name="{{name}}" {{"required" if required}}{{{'value': value}|xmlattr}}{{(attrs or {})|xmlattr}}>
             {% if icon_left %}
                 <span class="icon is-left">
@@ -30,10 +32,12 @@
         {% if caller %}
             {{ caller() }}
         {% endif %}
-    </div>
+    {% if not in_group %}
+        </div>
+    {% endif %}
 {% endmacro %}
 
-{% macro select(name, options_list, selected=none, required=false, multiple=false, class='') %}
+{% macro select(name, options_list, selected=none, required=false, multiple=false, class="") %}
     {# selection of elements with <select>
 
     @param name: name of the field
@@ -49,7 +53,7 @@
     </select>
 {% endmacro %}
 
-{% macro choices(name, choices_list, checked=none, class='') %}
+{% macro choices(name, choices_list, checked=none, class="") %}
     <div class="control {{class}}">
         {% for choice, label in choices_list %}
             <label class="radio" for="{{name|cur_gidx}}">
@@ -93,7 +97,7 @@
     {{ field("file", name=name, label=label, required=required) }}
 {% endmacro %}
 
-{% macro textarea(name, label="", rows=none, cols=50, placeholder='', help='', required=false) %}
+{% macro textarea(name, label="", rows=none, cols=50, placeholder="", help="", required=false) %}
     <div class="field form_input">
         {% set cur_id = name|next_gidx %}
         {% if label %}