1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Radio widget should use default if field/index is missing

Fixes #6389
This commit is contained in:
jeremy@jermolene.com 2022-01-09 17:17:12 +00:00
parent 927013a57a
commit 4e01fc1838
2 changed files with 5 additions and 5 deletions

View File

@ -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);

View File

@ -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;