Commit b7f53eb9 authored by Serge S. Koval's avatar Serge S. Koval

Minor template cleanup and ignore multicolumn properties when sorting

parent 3920b966
...@@ -316,9 +316,8 @@ class ModelView(BaseModelView): ...@@ -316,9 +316,8 @@ class ModelView(BaseModelView):
if hasattr(p, 'columns'): if hasattr(p, 'columns'):
# Sanity check # Sanity check
if len(p.columns) > 1: if len(p.columns) > 1:
raise Exception('Automatic form scaffolding is not supported' + # Multi-column properties are not supported
' for multi-column properties (%s.%s)' % ( continue
self.model.__name__, p.key))
column = p.columns[0] column = p.columns[0]
......
...@@ -73,14 +73,11 @@ ...@@ -73,14 +73,11 @@
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{% macro render_form_fields(form, focus_set=False) %} {% macro render_field(form, field, focus_set=False) %}
{{ form.hidden_tag() if form.hidden_tag is defined }} <div class="control-group{{ ' error' if field.errors }}">
{% for f in form if f.type != 'HiddenField' and f.type != 'CSRFTokenField' %}
<div class="control-group{{ ' error' if f.errors }}">
<div class="control-label"> <div class="control-label">
{{ f.label.text }} {{ field.label.text }}
{% if h.is_required_form_field(f) %} {% if h.is_required_form_field(field) %}
<strong style="color: red">&#42;</strong> <strong style="color: red">&#42;</strong>
{% else %} {% else %}
&nbsp; &nbsp;
...@@ -89,24 +86,31 @@ ...@@ -89,24 +86,31 @@
<div class="controls"> <div class="controls">
<div> <div>
{% if not focus_set %} {% if not focus_set %}
{{ f(autofocus='autofocus')|safe }} {{ field(autofocus='autofocus')|safe }}
{% set focus_set = True %} {% set focus_set = True %}
{% else %} {% else %}
{{ f()|safe }} {{ field()|safe }}
{% endif %} {% endif %}
</div> </div>
{% if f.description %} {% if field.description %}
<p class="help-block">{{ f.description }}</p> <p class="help-block">{{ field.description }}</p>
{% endif %} {% endif %}
{% if f.errors %} {% if field.errors %}
<ul> <ul>
{% for e in f.errors if e is string %} {% for e in field.errors if e is string %}
<li>{{ e }}</li> <li>{{ e }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% endmacro %}
{% macro render_form_fields(form, focus_set=False) %}
{{ form.hidden_tag() if form.hidden_tag is defined }}
{% for f in form if f.type != 'HiddenField' and f.type != 'CSRFTokenField' %}
{{ render_field(form, f, focus_set) }}
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment