Skip to content

Commit

Permalink
Grid(required_fields=...)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Aug 10, 2024
1 parent 6275a11 commit 4f1f33d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion py4web/utils/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
)
Expand Down

0 comments on commit 4f1f33d

Please sign in to comment.