qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
550 stars 103 forks source link

ACF: character limit validation error for standard fields #1292

Closed reekrd closed 1 year ago

reekrd commented 1 year ago

Validation of character limit for basic text fields fails because the string contains language information.

Create a new Basic Text field using ACF. Under validation set Character Limit to 10.

Now if you try to save this field with the value 'qwerty' you will see 'Value must not exceed 10 characters'

The function validate_value in class-acf-field-text.php sees the value [:en]qwerty[:] which is longer than 10 characters.

I did not now that language information was saved in basic text fields. Is this a somewhat new approach?

On our production server we have five languages enabled.

If I update a page or post where we use Basic Text fields they now contain all languages.

Basic text field value before updating the post: the text Basic text field value after updating the post: [:en]the text[:nl]the text[:de]the text[:es]the text[:fr]the text[:]

Validation needs to be done per language but validate_value does it on the entire string

PS we have been running qTranslate for years in this project before we migrated to qTranslate-XT

herrvigg commented 1 year ago

Related to #710. I may close one of the two tickets.

reekrd commented 1 year ago

Sure, close this one. Perhaps add to #710 that it also regards basic fields and not only ACF qTranslate Fields.

herrvigg commented 1 year ago

Indeed it might be different concerns between ACF standard fields and qTranslate extended fields.

herrvigg commented 1 year ago

I think I found a solution, merged in master. The validation will check the multilingual values for all standard fields that are enabled, potentially text/textarea/wysiwyg. Let me know how this works.

herrvigg commented 1 year ago

Released in 3.14.0.