ello there
To add dynamic options for a selection to the theme app blocks, you can use JavaScript to fetch the data from the metafields and populate the options for the selection field.
First, add the selection field to your schema as follows:
{ “type”: “select”, “id”: “my_select”, “label”: “My Select”, “options”: }
Then, in your JavaScript code, fetch the dynamic options from the metafields and populate them in the selection field as follows:
const mySelectField = document.querySelector('#my_select');
const options = "{{ app.metafields.myapp.some_select.value }}";
const optionsArray = options.split(',');
optionsArray.forEach(option => {
const newOption = document.createElement('option');
newOption.value = option;
newOption.text = option;
mySelectField.add(newOption);
});