[gen] Boolean field: bugfix (defaut layouts).
This commit is contained in:
parent
c11002b7d5
commit
fa9ef1b76c
|
@ -467,6 +467,15 @@ class Field:
|
|||
self.hasHelp = self.hasLayoutElement('h', layouts)
|
||||
return layouts
|
||||
|
||||
@staticmethod
|
||||
def copyLayouts(layouts):
|
||||
'''Create a deep copy of p_layouts.'''
|
||||
res = {}
|
||||
for k, v in layouts.iteritems():
|
||||
if isinstance(v, Table): res[k] = Table(other=v)
|
||||
else: res[k] = v
|
||||
return res
|
||||
|
||||
def hasLayoutElement(self, element, layouts):
|
||||
'''This method returns True if the given layout p_element can be found
|
||||
at least once among the various p_layouts defined for this field.'''
|
||||
|
|
|
@ -27,7 +27,7 @@ class Boolean(Field):
|
|||
trueFalse = {True: 'true', False: 'false'}
|
||||
|
||||
# Default layout (render = "checkbox") ("b" stands for "base").
|
||||
bLayouts = {'view': 'lf', 'edit': Table('f;lrv;=', width=None),
|
||||
bLayouts = {'view': 'lf', 'edit': Table('f;lrv;-', width=None),
|
||||
'search': 'l-f'}
|
||||
# Layout including a description.
|
||||
dLayouts = {'view': 'lf', 'edit': Table('flrv;=d', width=None)}
|
||||
|
@ -97,7 +97,9 @@ class Boolean(Field):
|
|||
self.pythonType = bool
|
||||
|
||||
def getDefaultLayouts(self):
|
||||
return (self.render == 'radios') and self.rLayouts or self.bLayouts
|
||||
cp = Field.copyLayouts
|
||||
if self.render == 'radios': return cp(Boolean.rLayouts)
|
||||
return cp(Boolean.bLayouts)
|
||||
|
||||
def getValue(self, obj):
|
||||
'''Never returns "None". Returns always "True" or "False", even if
|
||||
|
|
Loading…
Reference in a new issue