check that user made a selection in a list-* field if it's required. Fixes #5829
This commit is contained in:
parent
6cd341ad69
commit
2d9e622f65
|
@ -411,7 +411,11 @@ class ListSingleField(ListField, StringField):
|
||||||
"""
|
"""
|
||||||
Covers list-single field
|
Covers list-single field
|
||||||
"""
|
"""
|
||||||
pass
|
def is_valid(self):
|
||||||
|
if not self.required:
|
||||||
|
return True
|
||||||
|
if not self.value:
|
||||||
|
return False
|
||||||
|
|
||||||
class JidSingleField(ListSingleField):
|
class JidSingleField(ListSingleField):
|
||||||
"""
|
"""
|
||||||
|
@ -459,6 +463,12 @@ class ListMultiField(ListField):
|
||||||
for element in self.getTags('value'):
|
for element in self.getTags('value'):
|
||||||
yield element.getData()
|
yield element.getData()
|
||||||
|
|
||||||
|
def is_valid(self):
|
||||||
|
if not self.required:
|
||||||
|
return True
|
||||||
|
if not self.values:
|
||||||
|
return False
|
||||||
|
|
||||||
class JidMultiField(ListMultiField):
|
class JidMultiField(ListMultiField):
|
||||||
"""
|
"""
|
||||||
Covers jid-multi fields
|
Covers jid-multi fields
|
||||||
|
@ -665,8 +675,6 @@ class SimpleDataForm(DataForm, DataRecord):
|
||||||
# add <value> if there is not
|
# add <value> if there is not
|
||||||
if hasattr(f, 'value') and not f.value:
|
if hasattr(f, 'value') and not f.value:
|
||||||
f.value = ''
|
f.value = ''
|
||||||
if hasattr(f, 'values') and not f.values:
|
|
||||||
f.values = ['']
|
|
||||||
# Keep all required fields
|
# Keep all required fields
|
||||||
continue
|
continue
|
||||||
if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') \
|
if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') \
|
||||||
|
|
Loading…
Reference in New Issue