Automatically set date value dependent on another date field value in blueprints

Hey,

I’d like to set a deadline value which should always be 2 weeks before an event date.

   date:
      label: Event Date
      icon: calendar
      type: date
      translate: false
      default: today
      display: DD.MM.YYYY
      required: true
      width: 1/3
  deadline:
      type: date
      disabled: true 
      display: DD.MM.YYYY
      default: page.date - 2 week

since default values are set only once the page is created, I figured this would not work.
But can I somehow set that deadline date in another way?

Otherwise I’d have to fiddle around with ->sub(‘P14D’) on the date.
I failed to work that out so I hoped that I could simply set it somehow through the panel.

You could either use a page.update:after hook or a page model to set the value on save. But if I were you, I’d remove the field and create a page model method that displays the date on the frontend via PHP’s DateTime object (what you called fiddle around).

I’ll be using the deadline inside a controller as well.
How do I go about using page model methods inside a controller?

You don’t. You have to create a page model: Page models | Kirby CMS

If you have multiple page types, creating a custom page method in a plugin would probably make more sense: Pages methods | Kirby CMS