From 79b877f6b42b1395e204415435efe921f300ce50 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sat, 2 Dec 2017 13:52:20 -0600 Subject: [PATCH] create forms should not display default values for readonly fields (third attempt) --- gluon/sqlhtml.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 366fe634..aef106ff 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1346,8 +1346,14 @@ class SQLFORM(FORM): # will only use writable or readable fields, unless forced to ignore if fields is None: if not readonly: - fields = [f.name for f in table if (ignore_rw or f.writable or f.readable) and (not f.compute or record)] + if not record: + # create form should only show writable fields + fields = [f.name for f in table if (ignore_rw or f.writable) and not f.compute] + else: + # update form should also show readable fields and computed fields (but in reaodnly mode) + fields = [f.name for f in table if (ignore_rw or f.writable or f.readable)] else: + # read only form should show all readable fields fields = [f.name for f in table if (ignore_rw or f.readable)] self.fields = fields