In reply to: Daniel Krüger (Cosmo Consult)
Hi,
depending on the the amount of information and styling options the html fields would surely be the best option.
For you current solution you could create a form rule in JavaScript mode and hide/show the fields.
switch (G_BROWSER_LANGUAGE.substr(0, 2)) {
case "de":
HideField('#{FLD:5019}#');
ShowField('#{FLD:5020}#');
break;
case "pl":
break;
default:
break;
}
Alternatively you could prepare the data protection notice in the switch and add it to a container:
The below code is just an idea and is not tested, there can be syntax errors and the like.
<div id="dataProtection"></div>
<script>
var dataProtectionContent = ""
switch (G_BROWSER_LANGUAGE.substr(0, 2)) {
case "de":
dataProtectionContent =
`
My html content
`;
break;
case "pl":
break;
default:
break;
}
document.getElementById("dataProtection").insertAdjacentHTML("beforeend", dataProtectionContent );
</script>
If it's not to much content. you can also use a Business Rule which uses the Text function. This allows to define text in multiple languages and will display the correct one for the current user. But the other options would allow you to add some language selection. :)
Best regards,
Daniel
Hi Daniel,
Thank you very much for your support.
I was hoping that Webcon would be capable of a more sophisticated solution.
What I have now come to is the following solution.
I have created an HTML field and used the following configuration for it.
----------HTML Field Config----------
<div id="company_agreement_text"></div>
<script>
var DataProtectionNoticeField = document.getElementById("company_agreement_text");
DataProtectionNotice_de_DE = `
<p>A LOT of HTML</p>
`;
DataProtectionNotice_it_IT = `
<p>A LOT of HTML</p>
`;
DataProtectionNotice_default = `
<p>A LOT of HTML</p>
`;
if ("#{USERLAN}#" == "de-DE") {
DataProtectionNoticeField.innerHTML = DataProtectionNotice_de_DE;
} else if ("#{USERLAN}#" == "it-IT") {
DataProtectionNoticeField.innerHTML = DataProtectionNotice_it_IT;
} else {
DataProtectionNoticeField.innerHTML = DataProtectionNotice_default;
}
</script>
------------------------------------
Furthermore, in order to give the user the flexibility to display the data protection notice in different languages on the form, I decided to insert a choice field with the languages.
On the choice field I have created a form rule on value change (JavaScript Mode).
----------Choice Field form rule----------
var DataProtectionNoticeField = document.getElementById("company_agreement_text");
DataProtectionNotice_de_DE = `
<p>A LOT of HTML</p>
`;
DataProtectionNotice_it_IT = `
<p>A LOT of HTML</p>
`;
DataProtectionNotice_default = `
<p>A LOT of HTML</p>
`;
var LanguageSelected= GetPairName(GetValue('#{Language:ChoiceField}#'));
switch (LanguageSelected) {
case "German":
DataProtectionNoticeField.innerHTML = DataProtectionNotice_de_DE;
break;
case "Italian":
DataProtectionNoticeField.innerHTML = DataProtectionNotice_it_IT;
break;
default:
DataProtectionNoticeField.innerHTML = DataProtectionNotice_default;
break;
}
----------------------------------------
I realise that I could have written both solutions as well as <if else> or <switch case>. After I created the HTML field, I just wanted to try the <switch case> with the choice field, then I was just too lazy to rewrite the HTML field to <switch case> as well to stay consistent throughout. If it works, it works.
*Indeed, I hope that future versions of Webcon will offer better solutions in this direction.