Use select field to query files?

Is it possible to use a select field in the query of a files field?

To be more clear: Let’s say I have a site set up in which the user can create »Exhibition« pages and »Artist« pages. When creating an exhibition page, the user can select which artists should be featured in the exhibition, via a select field:

  type: select
  label: Artists featured in the exhibition
  options: query
  query: site.find("artists").children.published

I would now like to use the selection the user makes in this field, to tell a files field from which page it should query images. Is this possible? Or in other words, can I use the selection as a variable in the same blueprint?:

  type: files
  query: site.find(artistInExhibition).images

Are those fields in the same form (i.e. same page)?

Yes, the select field and the files field are part of the same blueprint/page


query: page.artistInExhibition.toPages.images

should work. But since you are on the same page, note that the values will not update before the page is actually saved because otherwise the second field doesn’t know anything about the first field.

You would have to create a custom field that listens to changes in the first field to make this works in real time.

1 Like

Thank you, this does solve my initial problem… now on to the next one: What if I want to select multiple pages (in the example case »Artists«) to fetch the images from?

Then use a pages field instead of a select field, which is the better option anyway.

1 Like

Thank you, thank you. Indeed the better solution :slight_smile: