Change field contents when another field is changed

Is there a way to connect the data from two fields together in the panel (blueprints definition)?

Say I have two date fields, date_1 and date_2
I want the second date field (date_2) to update when the first datefield (date_1) is edited by the user.

There is a static default setting:
default: today + 1day

So my question is, is there something like:
calculated: {date_1} + 1day

I need this, if it’s not standard available: what would be the best way to build this in?
I have the front-end javascript for this from another CMS. I’m seeking to port the site to Kirby.

Thx,
René

What is the purpose of the second date field? Is this supposed to be editable by the user?

Yes, both date fields are editable.

These are two dates for a course. The first date is entered by the user/editor. Then with every change in date_1, the second date is altered by the system to be the day after date_1.
Then the user can if needed alter the second date.

So the second date can be edited. If it is edited, it must be after the first date. But that’s a restriction I didn’t ask about in this question.

Hope you can help,
Thx, René

—/—

You can use a hook to alter the date on update. The downside of this approach is that the changes in this field will only be visible after saving. And since the value might have been edited by the user, you would have to make sure that it didn’t change in your hook.

The alternative would be a custom field that consists of two fields where the second listens to changes in the first. But that would require some coding skills.

Is there an opportunity in Kirby to add to the field’s properties?
Can I somehow code calculate: {field name} ?

There is a when: field property that I can maybe copy and use as a base?

Or can I add some JavaScript or Vue to the front end which will solve this?

Programming is no problem, I’m nee to Kirby and have sought through the documentation and forum, but until now I can’t find the easiest or preferred Kirby way to solve this.

Thanks,
René

—/—

Yes, but that wouldn’t help you, because the value would be calculated server side and you want to react to changes client-side.

I will attempt making a new fieldtype.

Thanks!

—/—