Is there a way to add an array item when defining props in a widget? For example I have this items below and I want to have like an array/list where I can add any number of items inside it:
The simplest solution would be to use a group item as input. If you need additional information for each item you could either use nested groups or custom item metadata.
In most situations, the group and tag options mentioned above are your best solutions, especially if you are then using an oh-repeater to get detailed api data about items. However, there is a built-in solution for more general arrays in parameters: the multiple property.
For example, the paramter:
- name: itemArray
label: Items
type: TEXT
context: item
description: A list of items
multiple: true
which allows you to selecte multiple items and the returned property just uses basic array indexing: props.itemArray[1].
The same is actually true for a text field as well. Adding multiple: true turns the text parameter input from a simple input box to a multiline textarea input and each line is an element in the returned array.
- name: textArray
label: Text list
type: TEXT
description: An array of text values
multiple: true