Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dale McCutcheon 22 posts 124 karma points
    Mar 28, 2018 @ 14:52
    Dale McCutcheon
    0

    Umbraco forms multi step - determine which step to show

    Hey all,

    Has anyone been able to determine which step to show and how to achieve this?

    Ideally i would like to pass something in the querystring like ?step=1 which would go to appropriate step - i have not been able to get a working solution for this yet.

    Anyone any ideas?

    Cheers Dale

  • ianhoughton 233 posts 433 karma points c-trib
    Oct 29, 2018 @ 12:02
    ianhoughton
    0

    Did you ever fix this?

  • Dale McCutcheon 22 posts 124 karma points
    Oct 29, 2018 @ 12:34
    Dale McCutcheon
    0

    Hey Ian,

    I actually implemented my own workaround as i could not find a way to fix this via umbraco.

    I am using a cookie when the user clicks whatever step they want to go to - it goes to a controller method sets a cookie then does a check on the Form.cshtml to check which step to go to and sets the model value.

    Can provide some more info if you need it.

    Cheers Dale

  • Daniel Dewhurst 3 posts 72 karma points
    Jul 09, 2019 @ 10:10
    Daniel Dewhurst
    0

    Please do expand, this would be useful to know.

  • Dale McCutcheon 22 posts 124 karma points
    Jul 12, 2019 @ 09:16
    Dale McCutcheon
    101

    Hey Daniel,

    So basically i had 3 buttons at the results page of my form which related to each step, If the user clicked on button 1 it would go to a controller passing a value of "step1" to the controller.

    I would then set a cookie within that controller method and return the user to the form page. When the form page loads it will hit Render.cshtml which lives in /Views/Partials/Forms/Themes/default/Render.cshtml - I carried out a check like so: -

      if (Request.Cookies["{{cookieName}}"] != null)
    
      {
    
        Model.FormStep = Convert.ToInt32(Request.Cookies["{{cookieName}}"].Value);
        if (Convert.ToInt32(Request.Cookies["{{cookieName}}"].Value) == 0)
        {
          Model.IsFirstPage = true;
        } else if (Convert.ToInt32(Request.Cookies["{{cookieName}}"].Value) == 2)
        {
          Model.IsLastPage = true;
          Model.IsFirstPage = false;
        }
        else
        {
          Model.IsFirstPage = false;
          Model.IsLastPage = false;
        }
        HttpCookie myCookie = new HttpCookie("{{cookieName}}");
        myCookie.Expires = DateTime.Now.AddDays(-1d);
        Response.Cookies.Add(myCookie);
    
      }
    

    This then allows you to control the model at point of rendering the form. Once the correct model values have been set i clear the cookie I had previously set in the controller.

    Hope this helps.

    Cheers

    Dale

Please Sign in or register to post replies

Write your reply to:

Draft