Using page function for the default value of a text field

I want to use a page function for the default value in a text field.
There is Is it possible to show the current date in query language? doing something similar. However, I can’t get it to work.
This is the blueprint of the field:

          tournee:
            label: Tournee
            default: "{{page.year}}"
            type: text

In the folder models I put a file with the same name as the blueprint file.
Its contents:

class Medienspiegelarchiv extends Page
{
    public function year()
    {
        return date('Y');
    }
}

When I open the page in the panel the textfield contains the string {{page.year}} instead of 2023.

What am I missing?

Thanks a lot for any feedback!

See documentation how to create a page model: Page models | Kirby CMS

Must be

MedienspiegelarchivPage

Thanks @texnixe I added the Page bit, but it still does not work.
if I change the blueprint to

          tournee:
            label: Tournee
            before: "{{page.year}}"
            default: "{{page.year}}"
            type: text

the before part appears correctly in the text field, but the default value does not. Is that a bug or just something that does not work for the default value?

I’m never really sure when query language works for default values or not, for most fields, query language does not work, but I thought it did for the text field.

Thanks, @texnixe – I hope this gets solved sometime, it seems I am not the only one trying to get it to work.

2 Likes