I’m trying to use the structure field for a quiz backend where each question is an entry in a structure field. The structure field contains question, answer-options (tags field) and a select field for choosing which of these options that is the correct answer.
Can’t figure out how to query the answeroptions - if possible:
quizentry:
label: Quiz entry
type: structure
fields:
question:
label: Question
type: text
answeroptions:
label: Answer options
type: tags
correctanswer:
label: Correct answer
type: select
options: query
query:
fetch: page.quizentry.toStructure.??? (can I dig into the structure here?)
text: "{{??structureItem.options???}}"
I don’t think this is possible. First, you want to select something that hasn’t even been stored yet, secondly, the structureItem selects a single field from all items in the structure, so selecting a field that itself contains an array wouldn’t be possible unless you use the API option for this. Then again, only once the content has been saved.
For this to work you would need a custom field plugin that uses JavaScript to read the tags from the answeroptions field and inject them on the fly into the correctanswer options.
Yes, but your result is not really what you need. While it should be possible to get the right values either through the API option or through a custom method, it wouldn’t make sense from a workflow perspective to first have to save and then revisit the field to select the correct answer.