12345678910111213141516171819202122232425262728293031 |
- {% macro input(fieldname, field, value='') -%}
- <label for="field_input_{{fieldname}}" class="col-sm-2 control-label">{{fieldname}}</label>
- <div class="col-xs-6">
- {% if value == None %}
- {% set value = '' %}
- {% endif %}
- {% if field.base_type == 'bool' %}
- <input id="field_input_{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="checkbox" checked="{% if value %}checked{% endif %}" >
- {% elif field.base_type == 'password' %}
- <input id="{{fieldname}}" name="field_input_{{fieldname}}" class="form-control" type="password" value="{{sval}}" >
- {% elif field.base_type == 'char' or field.base_type == 'int' %}
- <input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="text" value="{{value}}" >
- {% elif field.base_type == 'ref' %}
- {% if value is iterable %}
- {% set sval=value|join(',') %}
- {% else %}
- {% set sval = value %}
- {% endif %}
- {% if field.directly_editable %}
- <input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="text" value="{{sval}}" >
- {% set l_classe = field.allowed_classes %}
- <p> Please enter uids to instances of {{ l_classe.__name__ }} separated by commas </p>
- {% else %}
- <input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}" type="text" value="{{sval}}" readonly >
- <p> If you want to update this field, please do it in child objects</p>
- {% endif %}
- {% else %}
- Unsupported base type "{{field.base_type}}" <br>
- {% endif %}
- </div>
- {%- endmacro %}
|