Fixes #2007
This commit is contained in:
+4
-3
@@ -2023,7 +2023,7 @@ class SQLFORM(FORM):
|
|||||||
to hold the fields.
|
to hold the fields.
|
||||||
"""
|
"""
|
||||||
# this is here to avoid circular references
|
# 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.
|
# Define a table name, this way it can be logical to our CSS.
|
||||||
# And if you switch from using SQLFORM to SQLFORM.factory
|
# And if you switch from using SQLFORM to SQLFORM.factory
|
||||||
# your same css definitions will still apply.
|
# your same css definitions will still apply.
|
||||||
@@ -2036,8 +2036,9 @@ class SQLFORM(FORM):
|
|||||||
|
|
||||||
# Clone fields, while passing tables straight through
|
# Clone fields, while passing tables straight through
|
||||||
fields_with_clones = [f.clone() if isinstance(f, Field) else f for f in fields]
|
fields_with_clones = [f.clone() if isinstance(f, Field) else f for f in fields]
|
||||||
|
dummy_dal = DAL(None)
|
||||||
return SQLFORM(DAL(None).define_table(table_name, *fields_with_clones), **attributes)
|
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
|
@staticmethod
|
||||||
def build_query(fields, keywords):
|
def build_query(fields, keywords):
|
||||||
|
|||||||
Reference in New Issue
Block a user