Query certain page with the Quickselect field

How can I use the Quickselect field and limit the options to only the sub-pages it the page ‘projects’? I’ve attempted what I thought could work but I don’t think I’m close, any help would be greatly appreciated.

home.yml

linkpage:
    label: Linked Project
    type: relationship
    controller: FieldQuery::queryprojects
    placeholder: Choose an Project

plugins/myfieldqueries/myfieldqueries.php

<?php

class FieldQuery {
    static function queryprojects($field) {
        $kirby = kirby();
        $site = $kirby->site();
        $projects = $site->find('projects')->children()->visible();
    
        return $projects;
    }
}

You don’t need a controller, a simple query like you would use it in the select field is enough:

linkpage
  label: Linked Project
  type: quickselect # changed to quick select
  options: query
  query:
    page: projects
    fetch: visibleChildren
    text: '{{title}}'
    value: '{{uri}}'

In your above blueprint, your field type is relationship not quickselect?

1 Like