Forms confirmation redirection in a multilingual site
When using the formbuilder in a multilingual site and selecting the 'Redirect to a page' option, the value entered will be used for all languages.
In the sf_form_description table there is only one field (redirect_page_url), so I understand this option is not localized. Not being able to redirect to a new page decreases our options in terms of design and being able to measure visitors behavior in Analytics.
Is this by design and if so, will this missing feature be implemented in any of the upcoming releases? It would also help if you could use a page selector instead of a entering a string manually.
Hello Rein,
Thank you for contacting us.
Both translations of the form share the same form settings for redirect, check the url of the page in one language change it and it will be reflected in the other form too, this is the built in functionality for the forms module. All translation of the form are synced and this makes them share the same property for redirect page.
To overcome this create custom form control that extends the built in Forms widget. The sample class is provided below, in the highlighted method I insert IF condition that checks the current culture and if the page is in specific culture it performs redirect different than the configured page in the form itself.
namespace
SitefinityWebApp
public
class
CustomForm : FormsControl
protected
override
void
Submit_Click(
object
sender, EventArgs e)
// base.Submit_Click(sender, e);
this
.ProcessForm(
base
.FormData);
private
void
ProcessForm(FormDescription form)
if
(form ==
null
)
return
;
string
errorMessage;
if
(
this
.ValidateFormSubmissionRestrictions(form,
out
errorMessage))
if
(
this
.ValidateFormInput())
var beforeSaveArgs =
new
CancelEventArgs();
this
.OnBeforeFormSave(beforeSaveArgs);
if
(!beforeSaveArgs.Cancel)
this
.SaveFormEntry(form);
this
.OnFormSaved();
var beforeActionArgs =
new
CancelEventArgs();
this
.OnBeforeFormAction(beforeActionArgs);
if
(!beforeActionArgs.Cancel)
this
.ProcessFromSubmitAction(form);
else
// Restrictions
this
.FormControls.Visible =
false
;
this
.ErrorsPanel.Visible =
true
;
this
.ErrorsPanel.Controls.Add(
new
Label() Text = errorMessage );
return
;
protected
void
ProcessFromSubmitAction(FormDescription form)
if
(form.SubmitAction == SubmitAction.PageRedirect)
CultureInfo english =
new
CultureInfo(
"en"
);
if
(Thread.CurrentThread.CurrentCulture.ToString() ==
"en"
)
this
.Page.Response.Redirect(
"http://test.com"
,
true
);
else
if
(!
string
.IsNullOrEmpty(form.RedirectPageUrl))
this
.Page.Response.Redirect(form.RedirectPageUrl,
true
);
else
if
(form.SubmitAction == SubmitAction.TextMessage && !
string
.IsNullOrEmpty(form.SuccessMessage))
this
.FormControls.Visible =
false
;
this
.SuccessMessageLabel.Text = form.SuccessMessage;
private
bool
formDescriptionFound =
true
;
private
FormDescription formData =
null
;
private
const
string
groupValidationScript = @
"return Telerik.Sitefinity.Web.UI.Fields.FormManager.validateGroup("
"0"
")"
;