- π©πͺGermany geek-merlin Freiburg, Germany
Dup of β¨ Allow adding predefined lists to the options fields Needs work , that one has code.
See #2238085-37: [regression] options_allowed_values() signature doesn't allow for Views filter configuration β , where yched explains some assumptions/requirements related to "allowed_values_function" that isn't documented anywhere. In #2238085-42: [regression] options_allowed_values() signature doesn't allow for Views filter configuration β , I started adding that documentation. However, it's not easily discoverable: when writing a new allowed_values_function, you can add an @see to options_allowed_values() yourself, but how would you know to do that?
Furthermore, this function receives a $cacheable parameter. There's no clear explanation of what that means though. If your result varies by bundle but not by entity, is that cacheable? (yes). If your result varies by entity, is that cacheable? (no). The only way to know is to read the implementation of options_allowed_values() to see what it caches by. If we wanted to document this more prominently, where should we do that?
One possibility is to convert "allowed_values_function" into "allowed_values_class": then we can document everything via a PHP interface. We could even choose to make this class follow our already existing AllowedValuesInterface, for consistency. And maybe even implement cache information via our already existing CacheableInterface for even more consistency.
If we do that, we could go one step further, and annotate the class and make it a full-fledged plugin and convert options_allowed_values() into the plugin manager. This would allow the UI in ListItemBase::settingsForm() to present a drop-down rather than HEAD's current behavior of only letting you change the function outside of the UI. Note that entity_reference uses a SelectionPluginManager to manage its field type's allowed values, so we'd be joining good company.
Tagging as "beta target" as this might involve renaming the setting, and therefore, the config schema.
Closed: duplicate
11.0 π₯
options.module
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Dup of β¨ Allow adding predefined lists to the options fields Needs work , that one has code.