Pages field, can't query a collection

Hi there,

I can’t query a collection in a pages field.

/site/collections/products.php :

<?php

return function($site) {
    return $site->index()->template('product')
}

site.yml :

fields:
  products:
    label: Articles
    type: pages
    query: kirby.collection('products')

I don’t get any error, just an empty field :

Other attempts that didn’t work,
site.yml :

fields:
  products:
    label: Articles
    type: pages
    query: site.index.template('product')
fields:
  products:
    label: Articles
    type: pages
    query: site.index.filterBy('template', 'product')

/site/collections/products.php (and querying the collection in the field) :

<?php

return function($site) {
    return $site->index()->filterBy('template', 'product')
}

What am I doing wrong ?

Thank you for your help.

Do you get an error message or just no result? The code should work.

No error, just an empty field (I edit the question).

Well, the field is empty as long as nothing is selected. And no list to select from if you click on “Ajouter”?

Isn’t that supposed to display the existing product pages ? There are already two existing.
I can’t tell you what’s happening when I click the add button because the site isn’t working at all. I don’t know why, I’m searching.

No, a pages field is basically a select field, only for pages. Maybe it’s not what you want, though.

If you want to show existing pages and add new pages, then you probably want a pages section, instead of a field.