Populate select field's options based on another select field

I have a blueprint containing the following:

variations:
  label: Variations
  type: structure
  fields:
    key:
      label: Variation type
      type: select
      options: query
      query: site.page('settings').getVariationType() // "Used page model to fetch these"

    value:
      label: Variation options
      type: structure
      fields:
        text:
          label: Variation
          type: select
          options: 
            - "Options based on the choice made in the key query"
            - ...
            - ...

Is there a way to populate the value field options, based on the selected key option?

Not out of the box.

It would be possible via a custom route or query, but that would only work when the value of the key field is actually saved. But you want this to happen instantly, so you would need a custom field that listens to changes in the other field.

A workaround could be to create different values fields and show them conditionally depending on the key value selected. However, since your keys seem to be dynamic, that would not really work in this case.

Thanks @pixelijn. I wonder if a custom field plugin can get content from other pages, and fill the options.

Getting the options is not the problem. Your problem here is that you want to get the options on the fly, when the value of the key field is changed, but before this value is stored. So you need an event listener, that listens to changes in the key field and then fetches the options from a route and injects them into the value field.

See also: Programmatically change the content of the file field