Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle default values properly #503

Merged
merged 1 commit into from
Dec 4, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions Products/CMFPlomino/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ def getFieldValue(self, form, doc=None, editmode_obsolete=False,
if doc:
fieldValue = doc.getItem(fieldName)
#DBG _logger.info('BaseField.getFieldValue> 1 got doc')
elif self.context.Formula():
if (not fieldValue) and self.context.Formula():
# This implies that if a falsy fieldValue is possible,
# Formula needs to take it into account, e.g. using hasItem
fieldValue = form.computeFieldValue(fieldName, target)
#DBG _logger.info('BaseField.getFieldValue> 2 default formula')
elif request:
elif (not fieldValue) and request:
# if no doc context and no default formula, we accept
# value passed in the REQUEST so we look for 'fieldName'
# but also for 'fieldName_querystring' which allows to
Expand All @@ -128,7 +130,7 @@ def getFieldValue(self, form, doc=None, editmode_obsolete=False,
request_value = request.get(fieldName + '_querystring', '')
#DBG _logger.info('BaseField.getFieldValue> 3 request _querystring')
fieldValue = asUnicode(request_value)
else:
if not fieldValue:
#DBG _logger.info('BaseField.getFieldValue> 4 blank')
fieldValue = ""

Expand Down