Increase or remove default textfield #maxlength=128

Created on 4 January 2023, about 2 years ago
Updated 17 May 2023, over 1 year ago

Problem/Motivation

At https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-... there's no information at all about possible length limits for the several data types.

So when creating a config entity settings form (or anything else like that), you might assume that you can use data types like

  • string
  • label
  • ...

without having to care for a limit. For config entities, I guess that assumption is also absolutely correct (if it is, it would still be nice to write that down on the documentation page). For content entities that are stored into the database, of course limits are important. Still 128 isn't a good limit anymore?

Now, when creating the settings forms for the config entity, we were wondering that a text with > 128 characters could not be entered and was cut off in the UI.

The reason was the maxlength="128" attribute on the form elements. Okay so far, but strange default behavior.
Modifying this limit were unsure, if there's a technical limit, so that when changing this FAPI textfield element #maxlength and saving it, might lead to any kind of errors or just cut off text. As I couldn't find any documentation, we tried and couldn't find issues with that.

Later on, we used config translation to allow translating the values and run into the same issue again, now for the config translation form. To increase / remove the limit, we used a hook, until this is solved.
The issue came up with 🐛 Cookies Service Input fields limit text length too short Fixed at the COOKiES module.

Steps to reproduce

Follow the steps at https://www.drupal.org/docs/drupal-apis/configuration-api/creating-a-con... and try to enter a label with > 128 characters.

Even if there's no storage reason for the limit, the input is limited to 128 characters and changing this is hard.

Proposed resolution

There are several levels, where this might be solved, but I'm not experienced enough to decide the long term strategy.

These are the options from most global and BC-dangerous to BC-safe solutions:
a) Remove the #maxlength default from \Drupal\Core\Render\Element\Textfield entirely

b) Increase the #maxlength default at \Drupal\Core\Render\Element\Textfield to 256 to match at least 99% of the cases when making such an assumption

c) Unset the #maxlength limit at Drupal\config_translation\FormElement\Textfield

d) Increase the #maxlength limit at Drupal\config_translation\FormElement\Textfield to 256 to match at least 99% of the cases when making such an assumption

e) Introduce a maxlength or size similar property for config schema (abc.schema.yml) which is used to define the limits centrally and provide helpers to determine the limit.

f) ...?

Based on the results of the discussion here, possible the title and component of this issue might have to be changed accordingly.

Remaining tasks

Document the limits or that there is no technical limit at the Configuration schema/metadata docs page after that has been confirmed
Discuss which way to go

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

10.1

Component
Render 

Last updated about 4 hours ago

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.

Missing content requested by

🇦🇺Australia dpi
about 1 year ago
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024