You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
On publishing, the class-acf-field-text.php/acf-field-text::validate_field checks the $field['maxlength'].
It is not able to pre-filter the value through acf-qtranslate.
The acf-field-text also does not have a hook to interface with this.
Here's my workaround which I put in my theme/functions.php
add_filter('acf/validate_value', 'qtranslate_interfaced_validation', 10, 4);
function qtranslate_interfaced_validation($valid, $value, $field, $input) {
// class-acf-field-text.php/acf-field-text::validate_field checks the $field['maxlength']
// but is not able to pre-filter it's value through acf-qtranslate
// The acf-field-text also does not have a hook to interface with this.
//
// Here's a workaround:
// If $valid is 'Value must not exceed'-prefixed
// and $field['maxlength'] exists, we can be rather certain tat acf-field-text::validate_field has
// failed check.
// Perform the translation extraction and redo the check again.
//
// ///////////////////////////////////////////////////////////////////////////////////////
$prefix = 'Value must not exceed';
if (!function_exists('qtranxf_getLanguage')) return $valid;
if (!array_key_exists('maxlength', $field)) return $valid;
if (!is_string($valid)) return $valid;
if (!(substr($valid, 0, strlen($prefix)) === $prefix)) return $valid;
$active_language = apply_filters('acf_qtranslate_get_active_language', qtrans_getLanguage());
$value = explode("[:{$active_language}]", $value)[1];
$value = explode("[:", $value)[0];
if (strlen($value) > $field['maxlength']) {
return sprintf( __('Value must not exceed %d characters', 'acf'), $field['maxlength'] );
}
return true;
}
It would be really great if you can address this in acf-qtranslate please.
Thanks!
Bryan
Hillsong International
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
On publishing, the class-acf-field-text.php/acf-field-text::validate_field checks the $field['maxlength'].
It is not able to pre-filter the value through acf-qtranslate.
The acf-field-text also does not have a hook to interface with this.
Here's my workaround which I put in my theme/functions.php
It would be really great if you can address this in acf-qtranslate please.
Thanks!
Bryan
Hillsong International
The text was updated successfully, but these errors were encountered: