Problem
We currently have 3 list field types for floats, integer and text. Those field types do not provide a different data model than the regular float, integer or text field types - still they are totally different field types with totally different widgets and formatters.
Also, when we bake the API to set options into the field definition API as proposed by #2329937: Allow definition objects to provide options it would be strange DX when it would require you a certain field type for being able to use it also.
Proposed resolution
Merge the functionality of providing allowed values in the main field type and make the functionality optional. This comes with the advantage that you can easily switch back and forth between having allowed values or not and it allows for combinations not possible before, e.g. you could use a regular textfield widget for input numbers with allowed values 1-5, coming with different labels also.
Example use case: a textual input score field 1-10, which is limited from 1 to 10 and each level gets its own label used during display.
If we don't do this, list_text should be changed to list_string to match the new repartition of text/string field types.
Remaining tasks
Figure out the best way option widgets can identify compatible field types and do it.
User interface changes
List field types go away, all float, integer and text field types get a new optional allowed-values setting.
API changes
None, but the list of available field types changes.
Comments
Comment #1
catchThis would be a useful UX improvement (at least it definitely would for me), and it doesn't require any migration except for field types, so switching tags a bit.
Comment #2
yched CreditAttribution: yched commentedNote that this was the case in CCK D6, and the list field types were separated in D7.
IIRC, that was because "maybe it has a limited set of values, maybe it's open" was cumbersome for the eligibility of widgets and formatters (you could chose a select widget on a text field with no configured allowed values, and the dropdown was just empty / broken). That might be alleviated with the recent eligibility method in widget/formatter interfaces.
Also, it made the procedural code for those field types painful - but that may be alleviated by making ListItemBase a trait now ?
Last, this makes me think that, if we dont do this, list_text should in fact be list_string, to match the new repartition of text/string field types.
Comment #3
yched CreditAttribution: yched commentedMore thoughts:
- the combination of a list of "allowed values" with other settings intended to limit "open values" (max_length, min/max value) doesn't make much sense.
- list field types prevent the removal of an "allowed value" that is currently used in actual field values. Would we be able to do this in the case of a field that was "open values" so far and that gets assigned a list of "allowed values" at some point ?
In short, the field types were separated because in practice "open values" and "limited allowed values" have different logic and configuration, and allowing to changw back and forth between the two is both non trivial and not that much of an actual use case
Comment #4
BerdirI discussed this a bit with @catch in IRC, it is not an easy problem to solve, there are a few things that we need to think about:
- While we now have an API to dynamically figure out applicable widgets, we still assume that the default widget is always available. Switching to/from an allowed list of valued would result in a different default widget, I don't know how we're supposed to support that?
- Similar, if you change it for an existing field, then what happens with the existing display configuration that is now invalid?
- Widgets/Formatters can currently not apply to all field types, the isApplicable() stuff only works as a secondary layer.
- Currently, changing allowed values does validation, you can not remove an option if it is used. This is list field type specific logic, and if we want to keep that (not doing it could have problematic side effects too), we need to figure out a way to switch, otherwise a user has to know every value that is currently in the database or he will not be able to save it.
There was more, but I can't remember it right now...
Comment #5
fagoI thought it's important to get right now as it requires people to use the right field types when definiting their entities, however it would be easy to keep old list_* types in place for BC.
Yeah, when describing the use case above I was actually thinking that it sounds a bit like adding some labels for values of an "open values" field type instead of being a limited values field type.
We could move the default value definition to a method, what would help with #2342569: Decide on a strategy to handle huge lists of options also.
That is indeed tricky - we'd have update it to be the default widget when the current widget is not eligable any more :/
Agreed, so the form would become more complex then in order to reflect that.
hm, I guess we'd have to be picky when introducing allowed values or reducing them.
That would make sense to me.
Generally, I agree that this is no simple change and comes with quite some non-trivial edge-cases.
Comment #6
yched CreditAttribution: yched commentedMyself in #2:
Posted a patch in #2344979: Rename field type list_text to list_string. Since this issue here is still highly unsure, and the rename above would need to happen before beta, we want to move forward asap over there IMO.
Comment #7
jhedstromIs this issue still on the table for 8.0?
Comment #8
jhedstromI think this is too late for 8.0 at this time.
Comment #9
catchI think we could add the functionality to the core filed types, deprecate the old ones, possibly deprecate and hide list module itself on new installs.
Comment #10
jibranComment #11
andypostCan we have upgrade path for all configs that using types to rename?
Comment #13
xjmThis issue was marked as a beta target for the 8.0.x beta, but is not applicable as an 8.1.x beta target, so untagging.
Comment #14
Rebecca Crago CreditAttribution: Rebecca Crago as a volunteer commentedComment #27
quietone CreditAttribution: quietone at PreviousNext commentedUpdating tag.