From 62f537287621c8ab5fc3d3e5b6e405bc3ebf22dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Thu, 20 Sep 2018 12:47:05 +0100 Subject: [PATCH] Fixes #2007 --- gluon/sqlhtml.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 68d8014c..dfca9ff1 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2023,7 +2023,7 @@ class SQLFORM(FORM): to hold the fields. """ # this is here to avoid circular references - from gluon.dal import DAL + from gluon.dal import DAL, _default_validators # Define a table name, this way it can be logical to our CSS. # And if you switch from using SQLFORM to SQLFORM.factory # your same css definitions will still apply. @@ -2036,8 +2036,9 @@ class SQLFORM(FORM): # Clone fields, while passing tables straight through fields_with_clones = [f.clone() if isinstance(f, Field) else f for f in fields] - - return SQLFORM(DAL(None).define_table(table_name, *fields_with_clones), **attributes) + dummy_dal = DAL(None) + dummy_dal.validators_method = lambda f: _default_validators(dummy_dal, f) # See https://github.com/web2py/web2py/issues/2007 + return SQLFORM(dummy_dal.define_table(table_name, *fields_with_clones), **attributes) @staticmethod def build_query(fields, keywords):