- πΊπΈUnited States potassiumchloride
I have a use case. I want to use the same date field for two content types: event and document. The event node form needs to allow users to input month/day/year and start/end times. The document content only needs the year value. I would like to use the same field but different granularities on each content type. Why the same field? Well, when the two kinds of content share a field, then when the two types of content are mingled in a search index, I can create a facet for that single field and filter the results by year.
- π¨π¦Canada mandclu
It should definitely be possible to create a widget that only exposes a year dropdown, and then on submit would convert the selected value, for example to a start at Jan 1 of the selected year, and ending on Dec 31 of that year.
I could see a couple of ways of approaching this. One would be to update the existing SmartDateDatelistWidget class, though I don't think it's really designed to meet the needs of your specific use case. Another approach would be draw from the YearOnlyDefaultWidget in the Year Only module that @nord102 suggested.