Skip to content

Commit

Permalink
improved documentation and functionality for legacy class Row() in fo…
Browse files Browse the repository at this point in the history
…rm rules
  • Loading branch information
mccarthysean committed Jun 3, 2022
1 parent b4d40b8 commit 7839deb
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions flask_admin/form/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,39 @@ def __init__(self, rules, header=None, separator=''):


class Row(NestedRule):
def __init__(self, *columns, **kw):
super(Row, self).__init__()
self.row_classes = kw.get("row_classes", "form-row")
self.col_classes = kw.get("col_classes", "col")
self.rules = columns
"""
Bootstrap grid "row" div with automatic Bootstrap columns
"""
def __init__(self, columns=[], separator="", row_classes="form-row", col_classes="col"):
"""
Constructor
:param columns:
Child rule list of column names.
:param separator:
Default separator between rules when rendering them.
:param row_classes:
Space-separated classes to use for the Bootstrap row (e.g. "form-row justify-content-center").
Default "form-row"
:param col_classes:
Space-separated classes to use for the Bootstrap columns (e.g. "col-md-6").
Default "col"
"""
super(Row, self).__init__(rules=columns, separator=separator)
self.row_classes = row_classes
self.col_classes = col_classes

def __call__(self, form, form_opts=None, field_args={}):
"""
Render all children when called in the Jinja template.
:param form:
Form object
:param form_opts:
Form options
:param field_args:
Optional arguments that should be passed to template or the field
"""
cols = []
for col in self.rules:
if col.visible_fields:
Expand Down

0 comments on commit 7839deb

Please sign in to comment.