'schema': settings: options must be an array

Topic summary

A developer is attempting to add dynamic options to a selection field in Shopify theme app blocks using metafields. They want to populate the options array dynamically rather than hardcoding values.

Initial Approach:

  • Using metafields to store dynamic option values
  • Attempting to reference metafield values directly in the schema’s options array

Suggested Solution:

  • Set options as an empty array in the schema
  • Use JavaScript to fetch metafield data and populate the select field dynamically at runtime

Core Problem:
Shopify CLI blocks publication with validation error: “Invalid tag ‘schema’: settings: options can’t be empty” for select fields. The platform requires the options array to be populated in the schema itself, preventing dynamic population via metafields or JavaScript.

Current Status:
The issue remains unresolved. The developer expresses frustration that Shopify’s restrictions limit flexibility, suggesting the platform is intentionally reducing customization capabilities.

Summarized with AI on November 22. AI used: claude-sonnet-4-5-20250929.

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);
});
1 Like