How do I create a year-only drop-down field?
I want to create a Drupal 8 field that shows a year drop-down with 100 years to the current year.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
The Year Only module provides this feature by defining a new field type.
It comes with a range configuration.
It produces the following result in the entity (node, ...) edit form. Configured with unlimited number of values in this example.
I would personally recommend following https://drupal.stackexchange.com/a/242011/5438. It's a little more work with some coding but it doesn't mean you need to add another module that needs to be supported in relation to many drupal areas. You can use a List (integer) field and add things there.
You can can also use a field_integer textfield and use a form alterer.
You can use Date module.
This package contains both a flexible date/time field type Date field and a Date API that other modules can use.
When you add field you can choose what you want to show (day, month, year) and + and - from current year.