change the granularity of the date input

Created on 15 January 2021, about 4 years ago
Updated 19 February 2021, about 4 years ago

Hi,
for a new website I need to create a date field with the running time of a project.
I want to change the granularity of the date input - as I only the the year.

For exapmple:
Starting year: 2019
Ending year: 2021

Is it possible with smart date to show only the the year input field of start/end of the date field (not months, minutes, seconds) ?

thanks for feedback!

✨ Feature request
Status

Active

Version

3.1

Component

Documentation

Created by

πŸ‡¦πŸ‡ΉAustria inst

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡Έ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.

Production build 0.71.5 2024