Skip to content

Commit

Permalink
#324 fixing blank space at the top of forms
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar committed May 16, 2016
1 parent daa0368 commit dffa141
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/quickhowto/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from flask.ext.appbuilder.models.sqla.interface import SQLAInterface
from flask.ext.appbuilder.charts.views import GroupByChartView
from flask.ext.appbuilder.models.group import aggregate_count
from flask.ext.appbuilder.widgets import FormHorizontalWidget, FormInlineWidget, FormVerticalWidget
from flask.ext.babelpkg import lazy_gettext as _


Expand All @@ -25,7 +26,6 @@ class ContactModelView(ModelView):
list_columns = ['name', 'personal_celphone', 'birthday', 'contact_group.name']

base_order = ('name', 'asc')

show_fieldsets = [
('Summary', {'fields': ['name', 'gender', 'contact_group']}),
(
Expand Down
8 changes: 3 additions & 5 deletions flask_appbuilder/templates/appbuilder/general/lib.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,12 @@


{% macro render_field(field, begin_sep_label='', end_sep_label='', begin_sep_field='', end_sep_field='') %}
<div class="form-group">
{% if field.id != 'csrf_token' %}
{% if field.type == 'HiddenField' %}
{{ field}}
{% else %}
{{begin_sep_label|safe}}
<label for="{{field.id}}">
<label for="{{field.id}}" control-label>
{{ field.label.text }}
{% if field.flags.required %}
<strong style="color: red">&#42;</strong>
Expand All @@ -210,9 +209,8 @@
{% endfor %}
</div>
{% endif %}
{% endif %}
{{end_sep_field|safe}}
</div>
{{end_sep_field|safe}}
{% endif %}
{% endmacro %}


Expand Down
52 changes: 29 additions & 23 deletions flask_appbuilder/templates/appbuilder/general/widgets/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,48 @@
{% set begin_sep_field = '<td>' %}
{% set end_sep_field = '</td>' %}


{% if form_action %}
<form action="{{form_action}}" method="post" enctype="multipart/form-data">
{% else %}
<form id="model_form" action="" method="post" enctype="multipart/form-data">
{% endif %}
<form id="model_form" action="" method="post" enctype="multipart/form-data">
{{form.hidden_tag()}}

{% if fieldsets %}
{% for fieldset_item in fieldsets %}
{% if fieldset_item[1].get('expanded') == None %}
{% set expanded = True %}
{% else %}
{% set expanded = fieldset_item[1].get('expanded') %}
{% endif %}
{% call lib.accordion_tag(loop.index,fieldset_item[0], expanded) %}
{% for fieldset_item in fieldsets %}
{% if fieldset_item[1].get('expanded') == None %}
{% set expanded = True %}
{% else %}
{% set expanded = fieldset_item[1].get('expanded') %}
{% endif %}
{% call lib.accordion_tag(loop.index,fieldset_item[0], expanded) %}
<div class="table-responsive">
<table class="table table-bordered">
{% for item in fieldset_item[1].get('fields') %}
<table class="table table-responsive table-bordered">
{% for item in fieldset_item[1].get('fields') %}
{% if item not in exclude_cols %}
<tr>{{ lib.render_field(form[item], begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}</tr>
<tr>
{{ lib.render_field(form[item], begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
</tr>
{% endif %}
{% endfor %}
</table></div>
{% endcall %}
{% endfor %}
{% endfor %}
</table>
</div>
{% endcall %}
{% endfor %}
{% else %}

<div class="table-responsive">
<table class="table table-bordered">
{% for col in include_cols %}
{% set field = form[col] %}
<div class="table-responsive">
<table class="table table-bordered">
{% for col in include_cols %}
{% set field = form[col] %}
{% if field.name not in exclude_cols %}
<tr>{{ lib.render_field(field, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}</tr>
{% endif %}
<tr>
{{ lib.render_field(field, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</div>
{% endif %}

{{ lib.render_form_controls() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

{% import 'appbuilder/general/lib.html' as lib %}


{% if form_action %}
<form class="form-horizontal" role="form" action="{{form_action}}" method="post" enctype="multipart/form-data">
{% else %}
<form class="form-horizontal" role="form" id="model_form" action="" method="post" enctype="multipart/form-data">
{% endif %}
<form class="form-horizontal" role="form" id="model_form" action="" method="post" enctype="multipart/form-data">
{{form.hidden_tag()}}

{% if fieldsets %}
Expand Down

0 comments on commit dffa141

Please sign in to comment.