Hi
Please advise me how can I translate conatct us form?
Regards,
Tin Ma Ma
Hi
Please advise me how can I translate conatct us form?
Regards,
Tin Ma Ma
Hi Tin Ma Ma
That is currently not possible from the form administration. You have 2 other options though:
BR Nicolai
Hi Nicolai,
Thank you for your advice.
Point 2, Dropdown field cannot use @Translate method.
Regards,
Tin Ma Ma
Good point. It can be done by adding this code to your Form Template:
if (fieldType == "Checkboxlist" || fieldType == "Radio" || fieldType == "Select")
{
foreach (LoopItem option in field.GetLoop("Options"))
{
string optionText = option.GetString("Option.Text");
fieldControl = fieldControl.Replace(optionText, Translate(optionText));
}
}
It is a bit hacky and will not work with option texts like
[] a
[] Click for a
Since a would be replaced both places causing it not to translate...
Alternatively you can render the options manually in the template - something like this (Example not done):
if (fieldType == "Checkboxlist" || fieldType == "Radio")
{
foreach (LoopItem option in field.GetLoop("Options"))
{
int optionId = option.GetInteger("Option.ID");
bool optionActive = option.GetBoolean("Option.Active");
bool optionDefaultSelected = option.GetBoolean("Option.DefaultSelected");
string optionValue = option.GetString("Option.Value");
string optionText = option.GetString("Option.Text");
string optionChecked = "";
string optionHtmlId = String.Format("{0}{1}", fieldSystemName, optionId);
if(optionDefaultSelected && String.IsNullOrEmpty(fieldValue)) {
optionChecked = " checked";
}else if(!String.IsNullOrEmpty(fieldValue)){
if (fieldValue.Split((char)',').Contains(optionValue) || fieldValue == optionValue) {
optionChecked = " checked";
}
}
fieldControl = string.Format("<input type=\"{0}\" /> <label for=\"{1}\">{2}</label><br>", fieldType, optionHtmlId, optionChecked, optionText))
}
}
if (fieldType == "Select")
{
fieldControl = "<select xxx>"
foreach (LoopItem option in field.GetLoop("Options"))
{
fieldControl += "<option xxxx>"
}
fieldControl += "</select>"
}
BR Nicolai
Hi Nicolai,
Thank you for your advice.
Regards,
Tin Ma Ma
You must be logged in to post in the forum