Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing an issue where the search input field on an ACF relationship field is disabled in translated posts, this might be due to a change introduced in version 2.1.0 of the Advanced Custom Fields Multilingual (ACFML) plugin. This problem persists in version 2.1.3.
Solution:
We recommend modifying a line of code in the ACFML plugin. In the file

acfml/classes/class-wpml-acf-relationship-field.php

, change line 14 from:

$has_element_with_display_translated = true;

to:

$has_element_with_display_translated = false;

This change might resolve the issue. However, please note that this solution could become outdated or might not apply to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 32 replies, has 2 voices.

Last updated by johnS-9 1 year ago.

Assisted by: Lauren.

Author Posts
September 12, 2024 at 8:07 am #16169426

johnS-9

Hi Lauren,

Sorry but I disagree that this is a solution, it would fundamentally change how content is currently being shown on the site.

I would like the Publications post type to be in "fallback to the default language" mode. If I change it to "translatable only" then the other languages on my client's site will be missing a lot of content that was there before.

The reason I believe this is a bug is because "Translate or fallback to default" mode means there *might* be a translation. If there's not a translation then show the default language item. This behaviour is what we want, this has been a feature of WPML for a long time.

So surely it is a bug that ACFML is disabling fields in "Translate or fallback to default mode". It is a perfectly valid scenario for a translation to exist and for those fields to be editable.

For example:

English - Original language.

French - Translation exists, I want to be able to translate the fields in to French.

Spanish - Translation does not exist, so show the original language version (English).

Many thanks,

September 13, 2024 at 2:38 pm #16176348

Lauren
WPML Supporter since 10/2015

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I can understand why you would prefer to use Fallback to default. Our developers have intentionally set this field to disable with that option, but have found a workaround. I can't say for sure if this is something that will change permanently, that will be up to our development team. In the meantime, you can use this workaround:

In acfml/classes/class-wpml-acf-relationship-field.php line 14:

Set:

$has_element_with_display_translated = true;

To:

 $has_element_with_display_translated = false;

Please let me know if this resolves the issue.

September 16, 2024 at 11:12 am #16183258

johnS-9

Hi Lauren,

Thanks for the code change, that's helpful. I'm a bit apprehensive about applying patches to plugins that might receive an update and remove the patch.

I've added a new JS file to the admin area from my theme with this inside which should hopefully continue to work even if the plugin's updated. I'll see how this goes and revert to the PHP change if needed.

```js

$('.wpml_acf_annotation').prev().prop('disabled', false);
$('.wpml_acf_annotation.relationship').prev().find('input').prop('disabled', false);
$('.wpml_acf_annotation.taxonomy').prev().find('input').prop('disabled', false);

```

I would love if this change made it's way into an ACFML update.

Thanks for your help with this matter.