Commit 3bd55b2c authored by Sebastien Robin's avatar Sebastien Robin

patch to make Formulator returns 1 or 0 instead of True or False for

CheckBoxFields

update some patch of validation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@172 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e2d0c78a
...@@ -63,9 +63,7 @@ Field.render = PatchedField.render ...@@ -63,9 +63,7 @@ Field.render = PatchedField.render
from Products.Formulator.Validator import SelectionValidator from Products.Formulator.Validator import SelectionValidator
class PatchedSelectionValidator(SelectionValidator): def SelectionValidator_validate(self, field, key, REQUEST):
def validate(self, field, key, REQUEST):
value = StringBaseValidator.validate(self, field, key, REQUEST) value = StringBaseValidator.validate(self, field, key, REQUEST)
if value == "" and not field.get_value('required'): if value == "" and not field.get_value('required'):
...@@ -97,13 +95,11 @@ class PatchedSelectionValidator(SelectionValidator): ...@@ -97,13 +95,11 @@ class PatchedSelectionValidator(SelectionValidator):
# if we didn't find the value, return error # if we didn't find the value, return error
self.raise_error('unknown_selection', field) self.raise_error('unknown_selection', field)
SelectionValidator.validate = PatchedSelectionValidator.validate SelectionValidator.validate = SelectionValidator_validate
from Products.Formulator.Validator import MultiSelectionValidator from Products.Formulator.Validator import MultiSelectionValidator
class PatchedMultiSelectionValidator(MultiSelectionValidator): def MultiSelectionValidator_validate(self, field, key, REQUEST):
def validate(self, field, key, REQUEST):
values = REQUEST.get(key, []) values = REQUEST.get(key, [])
# NOTE: a hack to deal with single item selections # NOTE: a hack to deal with single item selections
if type(values) is not type([]): if type(values) is not type([]):
...@@ -149,4 +145,16 @@ class PatchedMultiSelectionValidator(MultiSelectionValidator): ...@@ -149,4 +145,16 @@ class PatchedMultiSelectionValidator(MultiSelectionValidator):
# everything checks out # everything checks out
return result return result
MultiSelectionValidator.validate = PatchedMultiSelectionValidator.validate MultiSelectionValidator.validate = MultiSelectionValidator_validate
from Products.Formulator.Validator import BooleanValidator
def BooleanValidator_validate(self, field, key, REQUEST):
result = not not REQUEST.get(key, 0)
if result==True:
return 1
else:
return 0
BooleanValidator.validate = BooleanValidator_validate
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment