From 7839debcde2115bb9af1e30f9949e2c5d4455c08 Mon Sep 17 00:00:00 2001 From: Sean McCarthy Date: Fri, 3 Jun 2022 11:59:32 -0600 Subject: [PATCH] improved documentation and functionality for legacy class Row() in form rules --- flask_admin/form/rules.py | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/flask_admin/form/rules.py b/flask_admin/form/rules.py index 50b766c130..e355c53715 100644 --- a/flask_admin/form/rules.py +++ b/flask_admin/form/rules.py @@ -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: