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.

Comments

weseze created an issue. See original summary.

weseze’s picture

Attached a patch to show the change I would make.

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.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.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.

weseze’s picture

Status: Active » Needs review
weseze’s picture

Issue summary: View changes
yogeshmpawar’s picture

StatusFileSize
new532 bytes

Straight reroll of #2.

Status: Needs review » Needs work

The last submitted patch, 7: 2973247-7.patch, failed testing. View results

yogeshmpawar’s picture

Status: Needs work » Needs review

Test failures are not related to patch.

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.

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.

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.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

#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.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This is a pretty interesting bug. This is happening because labels are mapped to Drupal\config_translation\FormElement\Textfield in config_translation_config_schema_info_alter(). Drupal\config_translation\FormElement\Textfield uses the default max length as set in \Drupal\Core\Render\Element\Textfield regardless 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_class in 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.

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.

lendude’s picture

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: Needs work » Postponed (maintainer needs more info)

@weseze as the original reporter does #3331028: Increase default textfield #maxlength=128 to 256 address this?

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: +Bug Smash Initiative

Believe the issue should be covered in the issue mentioned. If not we can always re-open

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.