Trouble with Default Values in Kirby 4.2: Object Field Value Not Outputting in Structure > Text Field

Hello everyone,

I’ve encountered an issue with Kirby version 4.2 that I’m hoping someone can assist me with. Here’s the problem:

In my setup, I have a parzelle.yml file and a models/parzelle.php file. Within parzelle.yml, I’ve defined two fields: one of type object and another of type structure. My objective is to have a default value displayed in the text field of the structure type, derived from a field within the object type.

Here’s an excerpt of my YAML configuration for clarity:

waterData:
  label: Wasser
  width: 1/2
  type: object
  fields:
    nummer:
      label: Zählernummer
      type: text
    hersteller:
      label: Hersteller
      type: text
    startEich:
      label: Eichjahr
      type: date
      display: YYYY
    endEich:
      label: gültig bis
      type: date
      display: YYYY

waterMeters:
  width: 1/2
  label: Wasser
  type: structure
  empty: keine Zählerstände vorhanden
  fields:
    year:
      label: Jahr
      type: date
      display: YYYY
      default: today
      disabled: true
    meter:
      label: Zählerstand
      type: number
    kennung:
      label: Zählernummer
      type: text
      disabled: true
      default: "{{ page.waterNumber }}"

Additionally, my parzelle.php model includes the following method:

public function waterNumber(): string
{
    $a = $this->waterData()->toObject();
    return $a->nummer();
}

However, the default value is being outputted as expected when I apply the query in a field of type headline.

Could someone please point out what I might be doing wrong here? Any assistance would be greatly appreciated.

Thank you in advance!

Most fields do not support query language for the default value. You would have to create a custom field, similar to what I suggested here: Dynamic default number field - #2 by texnixe

Thanks for the information, I really thought I had made a mistake somewhere.
I wanted to do it without a plugin.

With the plugin my problem is of course solved.

A note should then be included in your documentation.

I have seen/recognized this as a suggestion and solution based on the snippet.

Well, yes, manually setting default entries is possible, but that’s another story.

Okay, thanks for clarifying