You can now add multiple items to Reference Field Type

Hey Eric,

This would require some code. So if you’re build a form for a new actor, you’d need to have a dropdown field for movies. In the Connect Panel of that dropdown, toggle to make dropdown options connectable to another dataset and then connect those dropdown options to Movies collection. Make sure Dropdown value part is not connected.

Mind that you’d connect your dropdown options to Movies Title or similar human readable field, but the true unique identifier for the Movies is _id field.

Then, you need the following logic:

  1. Register onChange() handler and when it fires, based on title value, do wixData.query() to get item’s _id.

  2. Register onClick() handler on submit button (this button should not be connected to dataset) and when it fires, collect values from all other input fields, do wixData.insert() to submit the actor, and in the promise run wixData.insertReferenced() to submit the movie.
    Mind that we don’t currently have a multi value dropdown component, so if you want to submit multiple movies with single actor, you’d need to figure out a creative way with either using multiple checkboxes, repeater or something else. Essentially, you’ll be storing list of Movies and pass them to wixData.insertReferenced() when you submit Actor.

Hope that helps you to get started!