Skip to content

Commit

Permalink
noncreate -> showreadonly
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Nov 28, 2024
1 parent 3752e12 commit 26321fb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions py4web/utils/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def __call__(
errors,
readonly,
deletable,
noncreate,
showreadonly,
show_id,
kwargs=None,
):
Expand Down Expand Up @@ -348,10 +348,9 @@ def __call__(
continue

# if this is an create form (unkown id) then only show writable fields.
# Some if an edit form was made from a list of fields and noncreate=True
elif not vars.get("id") and noncreate:
if not field.writable:
continue
# Some if an edit form was made from a list of fields and showreadonly=True
elif not showreadonly and not field.writable:
continue

# ignore blob fields
if field.type == "blob": # never display blobs (mistake?)
Expand Down Expand Up @@ -684,7 +683,7 @@ def index():
:param record: a DAL record or record id
:param readonly: set to True to make a readonly form
:param deletable: set to False to disallow deletion of record
:param noncreate: make sure when you use a form with a list of fields that does not contain the id field, does not always render the create form.
:param showreadonly: show readonly fields True, False, or None for default behavior)
:param formstyle: a function that renders the form using helpers (FormStyleDefault)
:param dbio: set to False to prevent any DB writes
:param keep_values: if set to true, it remembers the values of the previously submitted form
Expand All @@ -704,7 +703,7 @@ def __init__(
record=None,
readonly=False,
deletable=True,
noncreate=True,
showreadonly=True,
formstyle=FormStyleDefault,
dbio=True,
keep_values=False,
Expand Down Expand Up @@ -757,7 +756,10 @@ def __init__(
self.vars = {}
self.errors = {}
self.readonly = readonly
self.noncreate = noncreate
# if showreadoanly is None only display readonly fields for edit for or non db based forms
if showreadonly is None:
showreadonly = self.record or isinstance(table, (list, tuple))
self.showreadonly = showreadonly
self.submitted = False
self.deleted = False
self.accepted = False
Expand Down Expand Up @@ -943,7 +945,7 @@ def helper(self):
errors,
self.readonly,
self.deletable,
self.noncreate,
self.showreadonly,
show_id=self.show_id,
kwargs=self.kwargs,
)
Expand Down

0 comments on commit 26321fb

Please sign in to comment.