I’ve got question regarding api fetch within multiselect fields.
We would like to fetch and use the following json in two option fields:
[
{
"region": "Europe",
"aliases": [
"EU"
],
"countries": [
{
"country": "Germany",
"aliases": [
"de",
"schland",
"deutsch"
]
},
{
"country": "Switzerland",
"aliases": [
"suisse"
]
}
]
},
{
"region": "North America",
"aliases": [
"NA"
],
"countries": [
{
"country": "United States",
"aliases": [
"US",
"USA"
]
},
{
"country": "Canada",
"aliases": [
"CA"
]
}
]
}
]
Currently, the first one is working as we expected it:
label:
en: Regions
de: Regionen
type: multiselect
translate: false
options: api
api:
url: "{{ site.url }}/distributors.json"
text: "{{ item.region }}"
value: "{{ item.region }}"
Now, we also need a field for countries:
label:
en: Countries
de: Länder
type: multiselect
translate: false
options: api
api:
url: "{{ site.url }}/distributors.json"
fetch: countries
text: "{{ item.country }}"
value: "{{ item.country }}"
How can we reduce the array or iterate over inner items with fetch to only retrieve the countries? Is that possible or do we have to write some php magic to reduce the array beforehand of the retrieval?
Cheers!
Ben