Linked element not submitting if value is set in code

Hi all,

Right now I’m working on a website that has a custom form to allow users to submit information to our collection. One of the columns is for custom tags. I have a search box that allows them to search for tags and to type out their own, then I have a Selection Tags element that populates with what they select by modifying the value and options attributes of the Selection Tags element. Then I have the Selection Tags element link to the collection submission.

// when an option from the search bar is clicked
$item("#tagSearchItemContainer").onClick(() => {
    let val = $item('#searchTagText').text;

    // set options and value to include 'val'
    $w('#tagCloud').options = $w('#tagCloud').options.concat(([{'label': val + ' x', 'value': val}]));
    $w('#tagCloud').value = $w('#tagCloud').value.concat(val);
});

That should be all well and good, but the submission never includes any of the tags. After doing some testing, it looks like Wix fails to submit any information if it is set manually in code (by modifying the value attribute). Is this a bug? Is it some sort of feature that I can get around? I can’t just populate the Selection Tags element with all of their options because I need to provide functionality for custom functions.

Thanks in advance,
Brett (✿◡‿◡)

You can either set the value via code or link directly to dataset. Attempting to do both will ‘confuse’ the system.

To set the value via code you can do a onbeforeSave …

https://www.wix.com/velo/reference/wix-dataset/dataset/onbeforesave

And set the value(s) …

https://www.wix.com/velo/reference/wix-dataset/dataset/setfieldvalue
https://www.wix.com/velo/reference/wix-dataset/dataset/setfieldvalues

#codequeen
#totallycodable