Date field min / max based on another field

Is there a way to use the value of one date field for the min or max value of another date field.

To elaborate, I have two date fields on the site blueprint that mark the start and end date of a festival.
On the artist blueprint there is a date field to select the day the artist performs. This field should have min and max dates based on the site date field.

So far I’ve tried the following settings on the artist date field:
min: site.event_from
min: site.event_from.toDate(‘d.m.Y’)
min: “{{site.event_from}}”
min: “{{site.event_from.toDate(‘d.m.Y’)}}”

I don’t think that property supports the query language. Not ideal, but i think if it was me I would set the available dates up by putting the the start and end date fields inside a structure field on the site page.

Then on the artist page, use a multi-select field instead of the date, and pull from the structure field dynamically with the query language to set the options with the available dates. That gives you the added bonus of being able to set artist performing on more than one day. Not ideal, but usable. I dont think there is another way.

You cannot count on the min and max values of the date field anyway, because the user can still pick any date via the date picker.

If you want to stick with a date field, I’d use the help property to display the possible dates and then use a hook that checks if the date is within the given range.

In case the alternative @jimbobrjames suggested (with a select or multi select) sounds like a good idea to you, I’d still not use a structure field to enter all possible dates but stick with the start and end dates and then use your own API (via a route) that returns a calculated array of dates between the start and end dates.

Thats a good idea too :slight_smile: I considered something like that but these kind of events tend to run over a weekend, so only talking 2 or 3 dates probably.

Which ever way makes most sense :slight_smile:

At least with the structure field you don’t have to start calculating date ranges… so it’s definitely less coding but more work for editors, depending on number of days.