I was probably overthinking this when I tried using reference fields but with a little help from Wix support which led me to find a solution, I finally figured it out! WITHOUT code (I know this forum is for Velo but if we can do it without code, why not share the knowledge).
I discovered I could update the reference fields in the back end Content Manager but couldn’t figure out how to put them on a form for my users to add or update. I didn’t want users anywhere near the back end Content Manager!!!
What to do:
- Create the reference field in the data collection (call it collection A ). When you create the item, you will be prompted to enter which data collection it references ( collection B ). It will use the primary key of collection B to fill into your new reference field in collection A .
- On your page, add data collection A with Write-only or Read-Write mode. On your form, add a dropdown input field. When you connect it to data collection A , choose the field that was the reference field (in my example above it is Mentor). Remember, this is done without page code. In my example, I’m using a repeater to contain my data items. (For details about displaying data items on a page, refer to CMS (Formerly Content Manager): Displaying Collection Content on a Regular Page | Help Center | Wix.com)
- The user will see a list of the primary items of data collection B you are referencing so they can choose one. NOTE : the drop down list cannot be filtered so this wouldn’t work well with a very large data collection. Also, notice what it says above for Connect a List - this is automatically done for you. When designing the primary key for your data collections, keep this in mind that the primary key field is what is displayed when you’re updating reference fields.
Furthermore, to display something from the referenced data collection B , when you connect a field, you will see the list of data items in the referenced collection. On my docent roster, I display FirstName LastName of the mentor.
This works when you reference other data collections or if you want to create a reference to the same data collection (which is what I did above). In my docent roster, I assign mentors to trainees which are also in the same data collection.
#reference #referenceFields