Problem/Motivation

Users generally default to using the Options module for pick lists, not realizing that Taxonomy is almost certainly the better choice. A Term Reference field can do everything an Options List can do in a more sustainable way, and has more features.

Some problems with Options lists:

  • Items can't easily be deleted.
  • Items can't easily be translated.
  • Items aren't fieldable.

Personally, I'm getting very tired of spending countless hours writing migration maps, converting list items to taxonomy terms, during major Drupal migrations. They data is usually bad ("dirty data") because list items cannot be managed as effectively as taxonomy terms can. However, users keep setting up fields with it because they don't know about or don't understand the repercussions.

As they're very simple data types and not entities, they're very difficult to work with in any framework sense. The only drawback to using the Taxonomy system instead is performance, as mentioned in #1677052-27: Rename the Options module (which contains the former List module as well):

It's not always the better choice, one advantage is that a list field is far more performant than a taxonomy reference because it doesn't require a separate entity/entities to be loaded when editing/viewing the entity. That's considerable overhead.

But I don't believe this to be much of problem in reality, as most of lists required by users are small (e.g. yes/no choices), or too large to be managed sustainably by Options (in which case Taxonomy would be used anyway). Also, we have much better on-by-default out-of-the-box caching in core nowadays, which should mitigate many performance concerns.

From #1677052-30: Rename the Options module (which contains the former List module as well):

I agree with @Berdir that list/options module might be more performant than taxonomy reference since Drupal doesn't have to load terms from DB, as long as it's not already in memcache. But as a service provider, I almost always prefer to use taxonomy terms than list/options. The problem is that once an option is used, it can not be deleted. If the client still wants to delete an option, we first have to delete it from wherever it has been used. That's a major headache that we want to avoid down the line.

Proposed resolution

  1. Deprecate the Options module in Drupal 8.
  2. Remove it from Drupal 9.
  3. Place it in Contrib for those folks that wish to keep it alive (e.g. for the few cases where performance is an issue).

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Comments

colan created an issue. See original summary.

berdir’s picture

> Items can't easily be deleted.

True, if they are used, but that's an explicit feature, not a bug, and that fact that entity reference fields don't validate/clean up causes left-over data and possibly broken content on your site.

> Items can't easily be translated.

They can be translated just fine using config translation. In fact, that allows to even deploy new, already-translated options from a staging to a production site.

> Items aren't fieldable.

Correct.

The middle point is IMHO the main reason why these fields absolutely are useful. List fields are configuration/site structure. They make sense when those options are tied to PHP/logic, because you can define machine names (foo|Foo) and rely on it in code. As mentioned, new options can be added in test environments and deployed.

So I'm definitely -1 on deprecating, what I'm sure we could improve is documentation, when to use what. entity references/taxonomy is useful when the list should be managed by users (admins), list fields when it is part of the functionality of the side and integrated with code (php or twig or even rules and so on). You don't want to rely on terms then that users could delete any time.

andypost’s picture

Another area to improve is ui for values and naming - there was issue about sorting List (human data type)
but as we have ER in core we should move in to core namespace and figure out common code with states from core workflow module

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

geek-merlin’s picture

Options are config, while terms are content. Totally different use cases. So -1.

colan’s picture

They're both config if you're using Structure Sync. ;)

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

chi’s picture

Worth noting that options can be defined for Number field type.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)

So for me this is a won't fix. Options has it's specific use cases that have already been mentioned.

Also the field_ui around options has greatly improved. Moving to PMNMI if someone heavily disagrees.

chi’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Per the above discussion no one supported deprecating options module.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.