commit 6ff51103f50b12746e8b147d984e09c753d42c41
parent 44fd5986992cfe5178b3bb70ff7883aeaec93aaa
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 20 Feb 2018 03:39:46 -0500
Make Zotero.ItemFields.getFieldIDFromTypeAndBase() work on non-base fields
This previously returned false if a non-base-mapped field was passed,
even if the field was valid for the given item type. It now returns the
passed field as long as the field is valid for the type, which matches
the behavior for base fields.
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/itemFields.js b/chrome/content/zotero/xpcom/data/itemFields.js
@@ -260,6 +260,11 @@ Zotero.ItemFields = new function() {
throw new Error("Invalid field '" + baseField + '" for base field');
}
+ // If field isn't a base field, return it if it's valid for the type
+ if (!this.isBaseField(baseFieldID)) {
+ return this.isValidForType(baseFieldID, itemTypeID) ? baseFieldID : false;
+ }
+
return _baseTypeFields[itemTypeID][baseFieldID];
}