I see I see, because it didnāt work that time. Iāve edited the post with a valid string.
Okay so Iāve figured out how to insert into the field onChange. But I donāt understand what you mean by this.
Store that using setFieldValue not setFieldValues .
$w(ā#myCollectionā).setFieldValue(ātagsFieldā: allTags)
Then you need to save that change using:
$w(ā#myCollectionā).save();
This is what I have;
$w.onReady(function () {
$w("#videoLibrary").setFieldValue("tags", allTags);
$w("#videoLibrary").save();
});
This gives me the following error on load;
DatasetError: There is no current item
If I add it to the submitButton_onClick I get this error on click;
save operation failed: DatasetError: Operation (save) not allowed during save
and it adds the whole string of tags to the field, I assumed it was supposed to do that but I donāt understand the purpose.
If I donāt add any of that code, it enters the tag into the field, but I get this error clicking the Submit Button;
save operation failed: TypeError: Cannot read property āreplaceā of undefined
And finally, even though I can get it to enter a tag into the field, it will only enter one of the selected tags (seems to be the last selected), how do I get multiple tags into the one field?
Here is my (redacted) code, without the above code;
var str = "tag 1\, + tag\,2\, + tag\.3\,"
+ " + tag\/4\, + tag\-5"
var allTags = str;
var tagItems = allTags;
var tagArray = tagItems.split('+');
var tag1 = tagArray[0];
var tag2 = tagArray[1];
var tag3 = tagArray[2];
var tag4 = tagArray[3];
var tag5 = tagArray[4];
export function tag1_onChange(event) {
$w("#myCollection").setFieldValues( {
"myField": tag1,
} );
}
export function tag2_onChange(event) {
$w("#myCollection").setFieldValues( {
"myField": tag2,
} );
}
export function tag3_onChange(event) {
$w("#myCollection").setFieldValues( {
"myField": tag3,
} );
}
export function tag4_onChange(event) {
$w("#myCollection").setFieldValues( {
"myField": tag2,
} );
}
export function tag5_onChange(event) {
$w("#myCollection").setFieldValues( {
"myField": tag3,
} );
}
Am I doing this right?