Hello everyone,
honestly tried to search this up, couldn’t find enough details to accomplish this without some help fro the community.
My tasks is to collect user input [and eventually store it in a collection] in a “multiple choices” situation where choices are coming from some other collection.
Say, I have a collections “Languages” [Title, ID] and “Student” [LastName, FirstName, ID, LanguagesSpoken]
What I was trying to get done was to create a CheckboxGroup, connect it to collection “Languages” [Title], allow user to choose one(many) languages by checking those boxes
and eventually save choices in my “Student” collection.
Perhaps my concept is not entirely correct, is CheckboxGroup the best option to visualize “multiple options” choice?
is column “LanguagesSpoken” going to be of type “Tags”?
could I somehow utilize ref.integrity model supported by Wix?
/* I am actually a database person simply trying to create a “one-to-many” relationship. */
Thanks in advance.
@givemeawhisky
my apologies for this belated response,
thank you for all the info, tons of useful data,
still I am a bit lost trying to figure out what would be the most efficient way to address my needs.
so, getting back to description of my initial task:
column “Student”.“LanguagesSpoken” should be of type “Reference”,
there I have to store 1…n _id values from “Languages” collection
what was done:
two tables created on this page,
one is connected with “Languages” via a dataset,
another is just a regular table with two columns - “Language” and “_id”
[choose] button click copies both “Language” and “_id” values from first to the second table,
[submit] button is supposed to save the info in “Student” collection as it is defined as dataset.submit
_afterSave function has to process second table, place all “_id” values in an array of references and save it in “Student”.“LanguagesSpoken” by calling wixData.insertReference
a minor issue here is that _afterSave is applicable to the dataset, but “insertReference” deals with collection.
I meant to use dataset getCurrentItem() function here.
still having troubles arranging my set of references, couldn’t find a solid example for this,
do I need to convert “_id” to a string before pushing it to array?
What do I miss?