If you want to connect an element to a collection field, you must choose whether you want to connect it yourself from the app, or allow site-builders to connect this element on their own. For example if you build an app with complex logic that you need to control, you would probably use the first option. If you build a more design-oriented widget and want to give site-builders the freedom to connect any field they want to the design, your would use the second.
Here are some details about these two options:
You can connect an element to a collection field in Blocks, through adding a dataset. If you do this, note that:
Go to the Repeater template to see an example of connecting elements to collection fields. The elements in this repeater are connected to the collection with no code.
You can also connect the elements through code.
You can also allow site builders to connect app elements to their site’s CMS through the Connect to CMS action button. If you choose to do this, note that:
If your widget has properties, adding this button to the action bar of entire widget, allows site builders to connect the widget properties to their data.