<form class="layui-form" method="GET" style="margin-bottom: 2rem">
  {% import math %}
  {% set pagebar.searchs += ['sort', 'order'] %}
  {% set pagebar.searchs += list(set(handler.request.arguments) - set(map(lambda item:item.split(':')[-1], pagebar.searchs))) %}
  {% set cols = 3 %}
  {% set rows = int(math.ceil(len(pagebar.searchs)/cols)) %}

  {% for i in range(rows) %}
  <div class="layui-form-item">
    {% for j in range(cols) %}
    {% if i*cols+j < len(pagebar.searchs) %}
       {% if pagebar.searchs[i*cols+j].find(':') >= 0 %}
       {% set label = pagebar.searchs[i*cols+j].split(':')[0] %}
       {% set field = pagebar.searchs[i*cols+j].split(':')[1] %}
       {% else %}
       {% set label = pagebar.searchs[i*cols+j] %}
       {% set field = pagebar.searchs[i*cols+j] %}
       {% end %}
       <div class="layui-inline">
         <label class="layui-form-label" title="{{ field }}">{{ label }}</label>
         <div class="layui-input-inline">
           {% if pagebar.options and field in pagebar.options %}
           <select lay-verify="" class="{{ field }}" name="{{ field }}" {% if pagebar.multiple and field in pagebar.multiple %}multiple{% end %} {% if pagebar.livesearch and field in pagebar.livesearch %}data-live-search="true"{% end %}>
             {% if not (pagebar.multiple and field in pagebar.multiple) %}
             <option value="">unlimited</option>
             {% end %}
             {% for option in pagebar.options[field] %}
             <option value="{{ option.split(':')[0] }}" {% if (isinstance(pagebar.get(field), (list, set)) and str(option.split(':')[0]) in map(lambda it:str(it), pagebar[field])) or str(option.split(':')[0]) == str(pagebar.get(field))  %}selected="selected"{% end %}>{{ option.split(':')[-1] }}</option>
             {% end %}
           </select>
           {% elif pagebar.types and field in pagebar.types %}
           <input class="layui-input {{ field }}" name="{{ field }}" value="{{ pagebar.get(field, '') }}" type="{{ pagebar.types[field ] }}">
           {% else %}
           <input class="layui-input {{ field }}" name="{{ field }}" value="{{ pagebar.get(field, '') }}">
           {% end %}
         </div>
       </div>
       {% else %}
       {% break %}
       {% end %}
       {% end %}
       {% if i == rows - 1 %}
       {% if j == cols - 1 and i*cols+j < len(pagebar.searchs) %}
  </div>
  <div class="layui-form-item">
    {% end %}
    <div class="layui-inline">
      <label class="layui-form-label">search</label>
      <div class="layui-input-inline">
        <button class="layui-btn">search</button>
      </div>
    </div>
    {% end %}
  </div>
  {% end %}

</form>
