From 4f1f33d95828d45458d899cad87e8620094e280a Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Sat, 10 Aug 2024 02:37:27 +0200 Subject: [PATCH] Grid(required_fields=...) --- py4web/utils/grid.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py4web/utils/grid.py b/py4web/utils/grid.py index a981f546..0889df16 100644 --- a/py4web/utils/grid.py +++ b/py4web/utils/grid.py @@ -307,6 +307,7 @@ def __init__( editable=True, deletable=True, validation=None, + required_fields=None, pre_action_buttons=None, post_action_buttons=None, auto_process=True, @@ -401,6 +402,7 @@ def __init__( delete_action_button_text="Delete", header_elements=None, footer_elements=None, + required_fields=required_fields or [], ) # instance variables that will be computed @@ -550,7 +552,8 @@ def compute(row, name=str(col)): raise RuntimeError(f"Column not support {col}") # join the set of all required fields - sets = (set(col.required_fields) for col in self.columns) + sets = [set(self.param.required_fields or [])] + sets += [set(col.required_fields) for col in self.columns] self.needed_fields = list( functools.reduce(lambda a, b: a | b, sets) | set([table._id]) )