Support

Account

Home Forums Add-ons Options Page Can't save options, empty translation

Solved

Can't save options, empty translation

  • Hello,

    I’m using latest versions of ACF pro (5.3.5) and WP (4.2.2). I’m using an option page, which I cannot save. The issue here is an empty alert, which shows up on form submit. After digging, I’ve found two unrelated issues :

    1. the alert is triggered in acf.field_group on submit event, which validates the content title $(‘#titlewrap #title’), and triggers the alert if empty. This selector do not match any element on option pages (which is logical as it does has not have any title like a post have) ;
    2. the label ‘title_is_required’ is not translated. It is not present in the acf.l10n object loaded in the page.

    If I manually disable the test in acf-field-group.js (line 430), the options are updated successfully. E.g. :

    if( $title.length && !$title.val() ) {

    This page used to work fine with previous versions of the plugin and WP.

    For the translation issue, the filter ‘acf/field_group/admin_l10n’ in acf_admin_field_group::admin_footer does not seem to be executed.

  • Since you included the word “translation” in the title of your topic I’m assuming this has something to do with a translation plugin. Which one is it? WPML? Does this happen on all options pages or just translations?

  • I’m not using any translation plugin. Maybe I should have used the word internationalization instead.

    The title validation issue happens on all option pages created using acf_add_options_page.

    I also deactivated all other plugins, which do not solve anything.

    The ‘title_is_required’ label translated to nothing issue is present regardless of the selected language of WP backend.

  • The reason that I asked is that I have tried to recreate this using the latest versions of ACF and WP and I don’t get any errors when saving an options page. Maybe it’s a theme issue? What theme are you using? It could also be a filter, have you added any filters or actions for ACF? You might want to try commenting those out. If you can narrow down the cause I might be able to help you figure it out.

  • I also tried changing the language on my test site and that did not cause the problem either. What language are you using on the site?

  • OK, I figured that out, it was my mistake. The issue was from a custom field type, for which I wrote some javascript, like documented in Adding custom javascript to fields.

    I introduce a dependency to acf-field-group.js, which forced loading it on every pages (and therefore activated the unwanted validation which was using unloaded internationalized string).

    I put my script file back on footer, removed the dependency, and it all works fine.

    The reason I first added this dependency (which is not documented), is that I had JS errors “acf is not defined” in pages where acf is not present (as wp_enqueue_script adds it to every pages). Before using acf.add_action, I added a test to ensure it is pertinent to go on :

    if (window.acf) {

    It seems that adding the dependency to acf-input.js do not cause issues, and may be a proper solution (to ensure WP loads custom scripts after it).

    Thanks a lot for your support.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.