Problem/Motivation
When you create a field as "List (text) (id: list_string)" You can create values for the keys that are "unlimited" in length. There is a limit because the input field is a textarea covering all the key/value pairs.
But, when translating this field, al the key/value pairs are split into separate textfields and the value for the textfield is defined as a "label" (in options.schema.yml), limiting it to 127 characters.
field.storage_settings.list_string:
type: mapping
label: 'List (text) settings'
mapping:
allowed_values:
type: sequence
label: 'Allowed values list'
sequence:
type: mapping
label: 'Allowed value with label'
mapping:
value:
type: string
label: 'Value'
label:
type: label
label: 'Label'
allowed_values_function:
type: string
label: 'Allowed values function'
This limitation is "wrong", because the actual values can be much longer without causing any problems.
Proposed resolution
Change the type of "Label" in options.schema.yml from "label" to "text".
Remaining tasks
Review the proposed solution.
User interface changes
The user interface for translating list_string field types changes so that labels are input in a textarea rather then a textfield.
API changes
None
Data model changes
Change the type of "Label" in options.schema.yml from "label" to "text.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2973247-7.patch | 532 bytes | yogeshmpawar |
| #2 | drupal-options-translate-char-limit-2973247-1-d8.patch | 523 bytes | weseze |
Comments
Comment #2
weseze commentedAttached a patch to show the change I would make.
Comment #5
weseze commentedComment #6
weseze commentedComment #7
yogeshmpawarStraight reroll of #2.
Comment #9
yogeshmpawarTest failures are not related to patch.
Comment #17
smustgrave commented#7 still applies to 10.1 and reran the tests with 0 failures.
NOT sure if this will need a change record or anything of those sorts.
Comment #18
alexpottThis is a pretty interesting bug. This is happening because labels are mapped to
Drupal\config_translation\FormElement\Textfieldinconfig_translation_config_schema_info_alter().Drupal\config_translation\FormElement\Textfielduses the default max length as set in\Drupal\Core\Render\Element\Textfieldregardless of the config.Looking at the underlying list string field we see that validation of this field is quite complex... \Drupal\options\Plugin\Field\FieldType\ListItemBase::validateAllowedValues. The UI for entering the allowed values presents a textarea where you can put one key|label pair per line. If there is no key then the label will be used as the key. At this point the label will be validated to be less than 256 characters. I don't think this impacts translation of the label because even if there is no key provided we store the key and label separately - so we can translate the label.
I wonder if we need to consider the usability impact of changing to textarea for all list string label translations. It would seem to me that we should switch between a textfield and textarea depending on the underlying configuration. We also need to decide what to do with new lines. With this change they would be possible in translated labels but not in untranslated labels. I think these considerations point towards a need for the options module to provide it's own
form_element_classin the config schema for the list string label.Also, we should consider how we tell the config translation system the max length of a label because I'm pretty sure that there are other labels that can be longer that the default textfield max length.
Comment #20
lendude#3331028: Increase default textfield #maxlength=128 to 256 might solve this too
Comment #22
smustgrave commented@weseze as the original reporter does #3331028: Increase default textfield #maxlength=128 to 256 address this?
Comment #23
smustgrave commentedBelieve the issue should be covered in the issue mentioned. If not we can always re-open