No, that is not possible. I already outlined how to set up the options above, the options must be flat.
fields:
category:
type: select
options:
option1: Health: Fitness & Nutrition
option2: Health: Alternative Health
option3: Arts: Fitness
option4: Arts: Design
option5: Arts: Bla bla
This will then save, for example, option1
in your content file. Each option must be a combination of one category and one subcategory.
Then you fetch the category and subcategory from the itunesOptions array via c::get()
.
$categories = c::get('itunesOptions');
// category for option 1
$category = $categories['option1']['category'];
$subCategory = $categories['option1']['subcategory'];
Edit:
Of course, instead of hardcoding option1
as array key, you would get the name of the key from your category field ($page->category()->value()
).
The itunesOptions
array has to look differently as well, as I already outlined above. Each option needs one category and one subcategory key. What you have above, with the same subcategory key used multiple times, doesn’t make sense. How do you want to fetch the value by key if you reuse the same key?
If you don’t want to type all the options out, you could try and use that json array you linked to above and create a list of options from it, which you could then use as dynamic options via a JSON API.