Skip Navigation

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

Problem:
The client has a custom post type called "Transaction" with an Advanced Custom Field of type Radio Button with options Yes and No. When using automatic translation, if the radio button is not selected in the original item, WPML incorrectly selects "Yes" in the translated version, allowing it to bypass required fields. This causes issues as the site relies on the Yes/No selection to determine if further fields should be present.

Solution:
We recommend setting all your groups to "Same fields across languages" in "ACF > Field Groups" to use the default configuration for each field type. This usually meets most clients' needs, with text fields being translatable and checkbox fields being copied.
If you need to fine-tune the translation preferences, switch to "Expert" mode for a particular group. You can then see and change the translation preference for each field.
You can find the recommended preferences for each field type here: Recommended Custom Fields Translation Preferences for ACF and WPML

If this solution doesn't look relevant to your issue, 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.

This topic contains 7 replies, has 2 voices.

Last updated by Nicolas V. 1 year, 1 month ago.

Assisted by: Nicolas V..

Author Posts
January 2, 2024 at 3:41 pm #15144015

johnM-108

SITUATION:

On my site, a custom post type ("Transaction") is using an Advanced Custom Field of type Radio Button. (See attachment "field-group.jpg")

There are two options: Yes and No.

No is the default option and the field is NOT required.

When I translate using automatic translation, it appears that if the radio button is not selected in the original item, WPML is choosing "Yes" in the translated version, which then allows it to save blank fields for all of the required/dependent fields (see attachment "result.jpg"), which is something that couldn't happen if the item were translated manually because the browser would detect the missing required fields.

This currently breaks the site because I rely on that Yes/No selection to determine if further fields should be present.

QUESTIONS:

Is there a way to make WPML NOT fill-out this radio box if the original item doesn't have a value saved for it?

If not, is there a way to force WPML to choose the Default value, which is what I would expect?

result.jpg
field-group.jpg
January 2, 2024 at 4:07 pm #15144151

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Welcome to the WPML support forum. To help speed up the support process, I've enabled a private message for submitting the debug information for this support ticket. Please follow these initial debugging steps:
https://wpml.org/faq/provide-debug-information-faster-support/
In short:
- Go to "WPML > Support > Debug Information" (link)
- Copy the Debug Information from there.
- Find the private field I activated and paste that information.

---

This file will allow me to check the translation preferences of your fields and see if they are set up correctly. This field should be set as "COPY", that way it will always match your selection from the original language.

Last, I see from the screenshots that you're editing the translation in the WordPress editor. Could you please also indicate your workflow? You mentioned automatic translation, so that means you're using our translation editor. I'm not sure why you're switching to the WordPress editor. (Could be just to see the error but I want to make sure it's not a workflow related issue as it's not recommended to switch editors).

January 2, 2024 at 4:20 pm #15144180

johnM-108

Added the debug information above.

Attached is a screenshot of:
Settings > Custom Field Translation (searching for the field name of "transaction_modal_check")

This should be set to "Copy" instead of "Don't Translate"?

Screen Shot 2024-01-02 at 11.17.52 AM.png
January 2, 2024 at 10:27 pm #15144929

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hi,

Thanks for the debug info.
- I see that you have our add-on "Advanced Custom Fields Multilingual" installed
- And yes the translation preference is incorrect ("Don't translate" instead of "Copy")

What intrigues me is that on the screenshot you shared in your first answer (hidden link), I don't see translation preferences, so it means that you're not using the "Expert" mode and if you were using the "Same fields accros languages" mode, that field would have been set to "Copy" by default.

You can change the translation preference in "WPML > Settings > Custom Field Translation" but I would recommend that you go to "ACF > Field Groups" instead. Then edit your group and select the "Same fields across languages" option in "Multilingual Setup".
That way all your fields will be configured with our default settings.

Once the change made, please make a small change on a post in the original language (like adding a space at the end of the post title). Save changes, and then enter the translation to re-validate it. This should be enough to apply the new translation preference.

January 5, 2024 at 4:30 pm #15155817

johnM-108

What I've experienced with adding WPML to an existing site is that "Translation Option" is not set to anything by default upon installing WPML and the ACF Multilingual plugins. (See "ACF Screen.png" attachment)

Should I be setting all of these to "Same fields across languages" by default, rather than leave them blank?

If so, I will do that, and then go through my field sets looking for required radio button sets to make sure they're set to "Copy" to prevent this issue in the future.

ACF Screen.png
January 5, 2024 at 5:06 pm #15155926

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Yes, that what I would recommend to do:
- Set all your groups to "Same fields across languages". This will use our default configuration for each field type. For example all text fields will be translatable while checkbox fields will be copied. This configuration fits clients' needs most of the time.

- After that, if you want to fine tune / adjust some translation preferences, you can switch to "Expert" mode for a particular group. You will then be able to see the translation preference of each field and change it.

You will find all the recommended preferences for each type here: https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/

You can change the translation preference of most fields. For example, if you use a text field for the "author name". A name doesn't need to be translated, so you can switch to "copy" instead of "translate".
Now, some special fields need a specific preference, here I'm talking about layout fields such as "Repeater" or "Flexible Content". Those fields need to be "copied".

January 5, 2024 at 6:49 pm #15156154

johnM-108

Thank you for all of your help. I have one more question before closing this ticket.

Here's the situation, which is essentially my situation and why I'm here.

I have an existing content type, let's call it "Products". The site has been around for a while so there are many existing Products in the system.

Today, I add a required radio button set with options of Yes and No to the Products post type.

Now, the existing Products can continue to exist without this radio button being checked either Yes or No, essentially being NULL. The only way existing Products will have this field filled-out is if someone edits the Product, in which case they will be unable to update the Product without selecting Yes or No.

However, if I were to install WPML and automatically translate all Products.... what happens with those existing Products with a NULL value for that field?

If I have the field in WPML set to "Copy" and the required field isn't filled-out, will the translated Product also have that field remain NULL?

I am assuming this is the case, and the reason my situation blew-up was because there was no setting for that field, in which case WPML chose ONE of the options by default... and I assume it chose the first option available which wasn't necessarily the one I set as required in ACF.

January 5, 2024 at 7:46 pm #15156192

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Unfortunately if the field is required WPML must add a value to be able to save the translation. But I think that if you set a default value for that checkbox in "ACF > Field Groups" then you should be able to update your existing products in bulk using the WordPress "Bulk Action" button.

Go to "Products", then select all 20 products from that list. Use the bulk action dropdown and choose "quick edit". The quick edit box will open, don't change anything, and click "Update". That should be enough to edit the 20 products and they should get the default value added.

PS: using the "Screen options" menu at the top right of your screen you can increase the 20 of post from 20 to 100 and bulk edit 100 products at the time.

January 8, 2024 at 4:58 pm #15162043

johnM-108

Nicolas,

Thanks for your response. It's not a big deal, but it doesn't look like a Quick Edit of a post sets a custom field value, even if it's required and has a default in ACF. Honestly, it would surprise me if it did.

I will keep what I learned here in mind when creating code that involves this scenario.