Currently, if the Force truncate and Safe truncate html options are both disabled, an author can exceed the maxlength limit on a formatted text field using CKEditor.

Some argue that JS validation should prevent this.

Another approach would be to add this as a configuration option. A use case for this is when adding a maximum text length restriction on a existing field, whose content may already be greater than the limit. We cannot enable Force truncate because that would lose data without warning the editor.

Comments

super_romeo created an issue. See original summary.

dakwamine’s picture

Same here, using adminimal theme. The counter works, but there is no validation.

I have tried with a user with no bypass permission.

Maxlength 1.0.0-beta5
Core 8.8.3

dakwamine’s picture

Some more info:

This occurred on formatted text, CKEditor. One would expect a JS validation to stop the form submit when the counter is negative, but it does not. To mitigate the issue, the Force truncate and Safe truncate html options must be used.

On raw text, all is fine.

renrhaf’s picture

Using the patch in https://www.drupal.org/project/maxlength/issues/2916687 allows to set a Javascript "soft" limit, but we should add an option to defined if a server side validation should occur. The use case is if we want, for example, to add a maximum text length restriction on a existing field, whose content may already be greater than the limit. We can not use truncate text here as we would loose data without warning the editor.

cedewey’s picture

Title: I can save node with exceeded text length » Add option to enforce maxlength server side.
Category: Support request » Feature request
Issue summary: View changes

I've updated the issue title and description for clarity. I've marked it as a feature request, though there's an argument to be made that it's a bug.

cedewey’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
cedewey’s picture

Status: Active » Closed (works as designed)

This feature request is no longer relevant per #2916687: Soft limit does not work on plain text fields because the Maxlength HTML attribute is used so marking closed, works as designed.