Is it possible to query select-field options from multiple structure fields and also offer the user to manually enter an option if none of the ones queried fits?
A specific example
Let’s say I’m working on the website of a company. The company has many employees, some of which belong to certain teams. An employee can belong to multiple teams at once.
The website should include a page on which a list of all teams is displayed. Let’s call this page »All Teams«.
Each item in the list on »All Teams« should include a (nested) list of the employees belonging to the team.
In the CMS, the user can create the teams for this list by creating/adding them to a structure-field.
This structure-field contains a nested structure-field in which the members of the team can be selected.
In this nested structure-field, the user should be able to select the members of a team from a select-field (rather than typing them in manually) OR type in the employee’s name manually if it is not included in the field’s options.
Question #1: Is it possible to create a field that accomplishes these two things at once (selecting an option or entering a manual option if none of the presented options fit the user’s need)?
Question #2: Is it possible to query the options of a select-field from multiple structure-fields?
To explain Question #2: Given the described example, because an employee can belong to multiple teams, ideally the select-field to select the members of a (newly created team) should query all team-members previously entered/added to other teams. So the field’s query would have to fetch all team-members of all other teams.
I hope this makes sense, please correct me or ask if there are mistakes in my logic.
Finally, I know another option to accomplish something similar would be to create a separate structure-field in which all employees are entered/stored and then query the entries of this field as the options of the select-field with which team-members are selected:
employees:
type: structure
label: Employees
fields:
name:
type: text
lable: Name of employee
teams:
type: structure
label: Teams
fields:
members:
type: select
options: query
query:
fetch: page.employees.toStructure
text: "{{ structureItem.name }}"
value: "{{ structureItem.name }}"
But, given that Question #1 can be answered with yes, it would be much nicer if the options were queried dynamically from the teams which have already been created.