I am trying to make a form to update a collection record.I’ve connected each input field to collection field with “Connected to Data” icon in Wix editor.
I am filling radiobuttons, drop-down lists and tags elements with options via my custom code.
What I noticed: drop-down lists work just perfect: they are filling with options and getting set to values from the current collection record.
Radiobuttons and tags behaves differently: the value sets first, and only after that the element filling with options.
For that elements I had to write extra async code which awaits when an element is filled with options and then set the correct value.
Would be great if all multiselect input elements will behave like dropdowns: which you can just connect to data and dont care of loading options and setting value operations order.
I am not sure, but this post here…
https://www.wix.com/velo/forum/community-discussion/wix-storage-checkboxgroup/p-1/dl-5fcc17364ce20b002d0ffbdf-5fcc15f3a032ca0034d80c97-1
Could perhaps help you (attention it’s a very big post, with lot of pages). Read all of them, perhaps you will look onto CheckBoxes / CheckBoxGroups from another view after reading all that content.
Well it seems that the referred post is mostly about the STRUCTURE of .options
My problem is about the ORDER of 1) loading options :
$w("myRadioButtons").options = fetchOptionsFromCollection();
and 2) setting the default value:
$w("myRadioButtons").value = fetchValueFromCollection();
Value setting is happening BEFORE loading of options, when there is no option to set yet.
For dropdowns I don`t even need to set the value, I just connect it to dataset in the editor and it works fine. But it doesn’t for radiobuttons and tags.
Or, in other words:
What is the correct (default, recommended, tidy, orthodox) method of loading options and setting values of a form input element?