I am attempting to update a widget so I can use data from an object rather than a text field in the widget.
The old get_settings looked like, and a text input is displayed on the widget to enter html.
hintText: {
main_label: "HintText",
csid: "HintText",
base_format: "text",
settings: { required: true, hint: "Use HTML tags to enhance your content" },
},
Text input on widget:
In the new get_settings I want to to load a list of Guided Hints from an object.
hint: {
main_label: "Hint text",
csid: "Hint text",
base_format: "choice",
choices: hint_choices,
settings: { required: true, hint: "Select the tip from the list" },
},
Choice list on widget showing dummy values
The problem I’m having is when I try and load data into hint_choices in the get_settings function it loads dummy data with negative ID’s (I’m guessing this a scope problem…?)
This is code in get_settings to pull list of hints.
get_settings: function () {
// *** DEV CODE (start) ***
// 1. Lookup all "Guided Hints" for Choice list
var hint_choices = {};
var allHints = cs.search({
'base_object_id':'object_guided_hints',
'selects':[':id', cs.ref('field_guided_hints__hint')],
'return':'data'
});
var i;
for(i in allHints) {
const hintid = allHints[i][':id']
const hintText = allHints[i][cs.ref('field_guided_hints__hint')]
hint_choices[hintid] = hintText;
}
// 2. Build Choices (X)
//hint_choices = cs.build_choices('object');
// 3. Hard Code array of choices (X)
//hint_choices = {"1": "aaaaaaaaaa <b>Hello</b>","2": "bbbbbbb <b>Hey</b>","3": "ccccccc <b>Hi</b>"},
// 4. O/P
cs.log('hint_choices ---> '+JSON.stringify(hint_choices));
// *** DEV CODE (end) ***
I’ve tried moving the code to different parts of the widget, but cant figure out how I pass the hint_choices into the get_settings function.
So what I’m asking is how do I populate hint_choices with the actual data, not the dummy?
Thanks
JonathanFS

