+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Forms confirmation redirection in a multilingual site

Forms confirmation redirection in a multilingual site

2 posts, 0 answered
  1. Rein
    Rein avatar
    22 posts
    Registered:
    07 Oct 2008
    24 Oct 2013
    Link to this post
    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.
  2. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    28 Oct 2013
    Link to this post
    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}"")";
        }
    }

    Register it in Administration->Settings->Advanced->Toolboxes->Toolboxes->pageControls->Section-><choose section>->Create New.

    Clr Type: SitefinityWebApp.CustomForm
    Title: CustomForm
    Name: CustomForm

    The way forms share form properties (the redirect page is a form property) is the expected way based on the forms implementation. The fact that a form shared the redirect page is the expected functionality based on the current implementation and I have logged a feature request to have separate form properties for different language versions of a form.

    Here is the feature request in PITS.

    Another way to go around this is to have separate forms for different languages.

    I hope this helps and please let me know if you have any additional questions.

    Regards,
    Pavel Benov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered