Tags query based on another field selection?

I have a module that can list posts from the blog or any other page that uses the “posts” template. Now I thought it would be cool to be able to filter posts by a specific tag. But since many pages might use the posts template, they each have their own collection of tags. Is it possible to have a query that only lists available tags based on the selection of the previous field?

posts:
  label: Posts
  options: query
  query: site.index.template('posts')
  type: select
  when:
    type: posts
  width: 1/2
postsFilter:
  label: Filter by tags
  options: query
  query: ? :/
  type: select
  when:
    type: posts
  width: 1/2

That is possible but only after the value is saved, so doesn’t really make sense. You would have to create a custom field. See this thread: Programmatically change the content of the file field

Thanks!

I finally went with a tags field instead. It serves as an autocomplete :+1:

posts:
  label: Posts
  options: query
  query: site.index.template('posts')
  type: select
  when:
    type: posts
  width: 1/2
postsTags:
  label: Filter by tags
  options: query
  query: site.index.pluck("tags", ",", true)
  type: tags
  when:
    type: posts
  width: 1/2