How can I create a "Year" picker?

Currently I use the Date field type.

And with options
{
“weekstart”: 0,
“format”: “YYYY”,
“cls”: “”,
“placeholder”: “”
}

But it was show a “Date” Picker which I still need to pick a “Day” before I can fill the field.

Any one know how can i control the “Date” picker to only show year?

1 Like

Hey @freedy82 and welcome to the Cockpit community :call_me_hand:

I have never faced such a requirement, but I think custom fields in combination with the documentation about fieldtypes might be interesting to you.
As far as I can tell, this still won’t allow you to make a “Year picker”, but you could create a select field with all available years by using “Multipleselect”. Definetly not the perfect way, but maybe a workaround.

@admins Just wondering. The docs say that the Date picker is “based on Spectrum.js”. But Spectrum seems to be a color picker. At least from what I have found. Is this a typo? :thinking:

2 Likes

You could try a Number field, with a minimum of 1900 and maximum of 2022 or so. Would that work for you?