From 4e01fc183820bb6ef6efd99f75345e9a9145e7bf Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sun, 9 Jan 2022 17:17:12 +0000 Subject: [PATCH] Radio widget should use default if field/index is missing Fixes #6389 --- core/modules/tiddler.js | 6 +++--- core/modules/widgets/radio.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/modules/tiddler.js b/core/modules/tiddler.js index e58d4ddf9..b0b6e6942 100644 --- a/core/modules/tiddler.js +++ b/core/modules/tiddler.js @@ -24,13 +24,13 @@ exports.isDraft = function() { return this.hasField("draft.of"); }; -exports.getFieldString = function(field) { +exports.getFieldString = function(field,defaultValue) { var value = this.fields[field]; // Check for a missing field if(value === undefined || value === null) { - return ""; + return defaultValue || ""; } - // Parse the field with the associated module (if any) + // Stringify the field with the associated tiddler field module (if any) var fieldModule = $tw.Tiddler.fieldModules[field]; if(fieldModule && fieldModule.stringify) { return fieldModule.stringify.call(this,value); diff --git a/core/modules/widgets/radio.js b/core/modules/widgets/radio.js index 22c9d8614..363836227 100644 --- a/core/modules/widgets/radio.js +++ b/core/modules/widgets/radio.js @@ -64,9 +64,9 @@ RadioWidget.prototype.getValue = function() { tiddler = this.wiki.getTiddler(this.radioTitle); if(tiddler) { if(this.radioIndex) { - value = this.wiki.extractTiddlerDataItem(this.radioTitle,this.radioIndex); + value = this.wiki.extractTiddlerDataItem(this.radioTitle,this.radioIndex,this.radioDefault); } else { - value = tiddler.getFieldString(this.radioField); + value = tiddler.getFieldString(this.radioField,this.radioDefault); } } else { value = this.radioDefault;