Increase or remove default textfield #maxlength=128

Created on 4 January 2023, over 1 year ago
Updated 12 April 2024, 6 months 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

- [X] Decide on an option: B for BC, A in a follow-up
- [X] Update issue summary
- [X] Create CR
- [ ] Framework Manager Review
- [ ] Release Manager Review
- [ ] Decide if this is to be done in a major release, see #15.
- [ ] Document the limits or that there is no technical limit at the Configuration schema/metadata docs page after that has been confirmed

User interface changes

None

API changes

?

Data model changes

None

Release notes snippet

Increased the default textfield #maxlength from 128 to 256

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Render 

Last updated 1 day ago

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

  • Needs release manager review

    It is used to alert the release manager core committer(s) that an issue significantly affects the overall technical debt or release timeline of Drupal, and their signoff is needed. See the governance policy draft for more information.

Missing content requested by

🇦🇺Australia dpi
10 months ago
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024