Lingua + Collections = Form Customization Weirdness

When using Lingua on a Collection resource and the system setting
lingua.form_customization is set to yes, all standard fields (pagetitle, longtitle, etc.) disappear on language switch in the manager. Switching back to the default language does NOT bring back the fields.

I am aware of “just turn the collection resource into a normal document, edit the fields and make the resource a collection again” workaround. But that is not practicable for my editors and contradicts the concept of form customization imho.

How can this be fixed?

It’s possible the two extras are not compatible as they both make changes to the resource form layout.
Are you getting any errors in the MODX log, or any errors in the browser console?

No errors. The translated fields exists, they are hidden via css (class: x-hide-display). This class should get removed once the language is switched - but it does not. Plus the initially visible fields get the class x-hide-display added, which results in NO fields shown at all.

This only occours in the document tab. It works in the TV tab aswell as in custom tabs.

When the page is loaded, the Lingua extra calls the function initFCRules() that determines, which fields are visible and which ones are not.

The problem when using Collections is, that when this function is called, the tab “Personen” is active and therefore none of the fields are visible. It only works when the tab “Dokument” is active at the time initFCRules() is executed.

So you have to change the code to make it work.

Here is one way that may work:

  • Delete the call to initFCRules() in the file assets/components/lingua/js/mgr/fcinit.js.
  • Add the following lines at the beginning of the function switchLanguage in the file assets/components/lingua/js/mgr/resource.js:
if (Object.keys(this.config.fcRules).length === 0){

Works perfectly, @halftrainedharry. Thank you very much for your detailed solution, that was very understandable written! Problem solved.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.