-
I am coding a dashboard page that is used to enter data into my website
-
Dashboard page uses multi checkbox fields to categorize content
-
Through code, checkbox data is assigned to a selectionTag element that is connect to data
-
Tags appear in selectionTag element properly but are not saved on button submit to the connected data field in the collection
Here is a screenshot of the selectionTags element on the dashboard page showing it connected to data:
Here is a screen shot of the dashboard page with the selectionTag element being populated through code from the checkbox selections:
Here is the code being used to take the checkbox array data and assign it to the selectionTag element:
if (checkboxArray.length === 0) {
console.log("checkboxArray is 0");
} else {
let tagLength = checkboxArray.length;
let selectionTagOptions = [];
console.log("the tag length of checkboxArray is: ", tagLength);
for (let i = 0; i < tagLength; i++) {
selectionTagOptions.push({ 'label': checkboxArray[i], 'value': checkboxArray[i] });
$w("#selectionTags").options = selectionTagOptions;
console.log("selection tag option: ", selectionTagOptions);
}
Here is a screenshot of the collection that the selectionTags are connected to showing nothing saved in the collection field for the new test entry:
I would greatly appreciate any ideas or help 
Thank you!
Where is your CODE which do the saving of your items into database ?
Something like this one…
$w.onReady( () => {
$w("#myDataset").onReady( () => {
$w("#myDataset").setFieldValue("title", "New Title");
$w('#btnSave').onClick(()=>{
$w("#myDataset").save();
});
});
});
Thank you so much for your quick reply.
All the fields on the dashboard page, including the selectionTags field, are connected to the catalog dataset and get saved when the user clicks the save button which is setup to submit.
Mixing code and the options inside properties panel in most cases ends in total CHAOS!
You are running into same direction.
- either you do everything by code
- or you do everything through properties-panel (but through properties panel you won’t have all the possibilities, what you can do by code).
Mixing both will give you a lot of headaches.
Thank you so much for your reply @Velo-Ninja I am going to take your advice and convert everything to code.
I did come across a solution to my problem. In order to save the tags to the database using button submit with connected data, I changed the code to save the selectionTags value instead of the options. So, the following code now saves the data:
I used this:
$w("#selectionTags").value = selectionTagOptions;
instead of:
$w("#selectionTags").options=selectionTagOptions;
if (checkboxArray.length === 0) {
console.log("checkboxArray is 0");
} else {
let tagLength = checkboxArray.length;
let selectionTagOptions = [];
console.log("tagLength is: ", tagLength);
for (let i = 0; i < tagLength; i++) { selectionTagOptions.push(checkboxArray[i]);
$w("#selectionTags").value = selectionTagOptions;
console.log("tag option: ", selectionTagOptions);
}
$w("#datasetCatalog").setFieldValues( {"collection": selectionTagOptions});
}
Thanks again for your help.