From eb397b41652eda46b9b3738627afba6398e54f71 Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 21 Nov 2018 15:10:43 -0700 Subject: [PATCH] Etemplate - for value widget sums, treat empty fields as 0 --- api/js/etemplate/et2_widget_entry.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/et2_widget_entry.js b/api/js/etemplate/et2_widget_entry.js index d486efda46..928b220fa9 100644 --- a/api/js/etemplate/et2_widget_entry.js +++ b/api/js/etemplate/et2_widget_entry.js @@ -155,9 +155,9 @@ var et2_entry = (function(){ "use strict"; return et2_valueWidget.extend( var fields = this.options.alternate_fields.split(':'); for(var i = 0; i < fields.length; i++) { - var value = (fields[i][0] == "-")? this.getArrayMgr('content').getEntry(fields[i].replace('-',''))*-1: - this.getArrayMgr('content').getEntry(fields[i]); - sum += parseFloat(value); + var negate = (fields[i][0] == "-"); + var value = this.getArrayMgr('content').getEntry(fields[i].replace('-','')) + sum += typeof value === 'undefined' ? 0 : (parseFloat(value) * (negate ? -1 : 1)); if(value && this.options.field !== 'sum') { widget.options.value = value;