How to bypass required theme.ini element date field?

Hi there,
I want to include an OPTIONAL date field in my theme.ini file, but it’s requiring that it is filled before saving. Does anyone know of a way to bypass this requirement? The date is only needed if the first question is yes, that the site is sunsetted. Here is what I have in my theme.ini file for this segment:

elements.sunsetsite.type = “select”
elements.sunsetsite.name = “sunsetsite”
elements.sunsetsite.options.label = “Is this site sunsetted?”
elements.sunsetsite.options.info = “Is this site no longer accepting updates and should remain limited?”
elements.sunsetsite.options.options.no = “no”
elements.sunsetsite.options.options.yes = “yes”

elements.sunsetdate.type = “date”
elements.sunsetdate.name = “sunsetdate”
elements.sunsetdate.options.label = “When was this sunsetted?”
elements.sunsetdate.options.info = “Please select the date in which this site is no longer supported”

Thanks!

I think the issue is that a date input is “required” by default, and we don’t provide a way for themes to set that required flag. Some form elements provided by Laminas are like this, and start out as “required” while most don’t.

So, the answer is basically that you can’t use a Date input for a theme config setting right now. You could use a workaround instead, a simple text field, or possibly using the “pattern” attribute if you want to force input in a particular date format (but you won’t get the calendar-picker interface).

Ahh ok, thank you so much for pointing this out and saving me more headaches trying to research a solution that doesn’t exist! I do like your workaround idea though, of just using a simple text field and perhaps using the pattern attribute. I haven’t used that before but I will look into it. Thanks!

We’re looking into changes we can make on our end to allow more elements like this in the future, as well.

1 Like