Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 09:45
    Graham Carr
    0

    Form Steps Issue

    I have stumbled into an issue which I find very strange and not sure why it is happening. If I set the FormStep via jQuery and click the Next button all seems to work fine except that the values are not actually stored when I submit the form or re-open it for that matter, the same happens with the Previous button. If I click Next/Previous without setting the FormStep via jQuery then it saves the values fine.

    Do you have any idea why this might be happening?? For your reference this is the code I am running in a customised Form.cshtml specific to the form in question:

        <script type="text/javascript">
            $
    (document).ready(function () {
                $
    (".next").click(function () {
                   
    if($("#b0a3522d-4daa-47f1-8760-72107507afc6").val() != null) {
                       
    switch ($("#b0a3522d-4daa-47f1-8760-72107507afc6").val()) {
                           
    case "New starter":
                                $
    ("#FormStep").val("3");
                                $
    ("#RequestType").val("New Starter");
                               
    break;
                           
    case "Change of personal details":
                                $
    ("#FormStep").val("4");
                                $
    ("#RequestType").val("Change of Personal Details");
                               
    break;
                           
    case "Contract extension":
                                $
    ("#FormStep").val("5");
                                $
    ("#RequestType").val("Contract Extension");
                               
    break;
                           
    case "Contract amendment":
                                $
    ("#FormStep").val("6");
                                $
    ("#RequestType").val("Contract Amendment");
                               
    break;
                           
    case "Leaver":
                                $
    ("#FormStep").val("7");
                                $
    ("#RequestType").val("Leaver");
                               
    break;
                           
    case "Maternity/Adoption leave":
                                $
    ("#FormStep").val("8");
                                $
    ("#RequestType").val("Maternity/Adoption Leave");
                               
    break;
                       
    }
                   
    }
                   
    if ($(".nextpage").val() != null) {
                       
    var currentPage = parseInt($(".nextpage").val(), 10);
                        $
    ("#FormStep").val(currentPage);
                   
    }
               
    });
                $
    (".cancel").click(function () {
                    $
    ("#FormStep").val(2);
                   
    if ($(".previouspage").val() != null) {
                       
    var currentPage = parseInt($(".previouspage").val(), 10);
                       
    ++currentPage;
                        $
    ("#FormStep").val(currentPage);
                   
    }
               
    });
           
    });
       
    </script>

    I have attached some screenshots to show the difference between when the FormStep is set via jQuery and when it is set as normal. As you can see, another issue is that the validation is hit as soon as the form step appears when the step has been set via jquery as opposed to that not happening when the form step is left as normal. For your reference the PreviousFormStep and NextPageNumber are custom fieldtypes I have created to be able to specify which page should be shown on the next and previous button clicks as per the code above.

    FORM STEP SET VIA JQUERY

    FORM STEP NOT SET VIA JQUERY

  • Comment author was deleted

    Nov 03, 2014 @ 12:26

    Thanks for these details will see if I can reproduce the behaviour, but since this is a bit of a hack I'm not quite sure we'll get it 100% working

    Will keep you updated

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 12:32
    Graham Carr
    0

    Thanks Tim, I really want to use Contour for this project as it allows the admin users a convenient way of updating the forms using a method they are already familiar with, plus I would just like to prove that Contour could be used for a project such as this as I would then use again for similar in the future. I don't mind if it is a bit of a hack so long as I can find a way of making it work without having to resort to doing a bespoke build for the form functionality.

  • Comment author was deleted

    Nov 03, 2014 @ 12:39

    Ok I can reproduce the behaviour and I understand why this is happening, when you set a formstep it will validate and submit that step. Looking into the code if there is a easy and clean way of adding this functionality

  • Comment author was deleted

    Nov 03, 2014 @ 12:42

    I might add 2 hidden inputs prevstep and nextstep that you can then set in jquery and it will use those values to determine which page to go to , that doesn't mess with the formstep one that is used for validating and storing data 

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 12:45
    Graham Carr
    0

    You are a star, if you can add this then that would be perfect and means I then know for sure I can do the full project using Contour as everything else I am trying works perfectly.

  • Comment author was deleted

    Nov 03, 2014 @ 12:48

    Yup think that will work :) adding the bits now and will have something for you to test today/tomorrow

    Cheers,
    Tim 

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 13:00
    Graham Carr
    0

    Thank you very much, just let me know the download link when you have a version available to test, for your reference the version I am using of Contour is 3.0.21 and running the site on Umbraco 6.0.5

  • Comment author was deleted

    Nov 03, 2014 @ 13:51

    Ok got a WIP build for you, you can download it here http://nightly.umbraco.org/Umbraco%20Contour/3.0/UmbracoForms.files.3.0.23.WIP-Build.17.zip

    To upgrade from your version follow the instructions here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Installation/Upgrade

    Then you can set PrevStep and NextStep instead of FormStep

  • Comment author was deleted

    Nov 03, 2014 @ 13:53

    let me know if that works

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 14:13
    Graham Carr
    0

    Thanks Tim, I will let you know as soon as I have had chance to give it a test :)

  • Comment author was deleted

    Nov 03, 2014 @ 14:13

    Great :)

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 14:38
    Graham Carr
    0

    I have just dropped the new version in and given it a quick test and setting the NextStep and PrevStep hidden fields via jQuery works perfectly. The validation is working as it should and form values are also being saved moving forwards and backwards as they should, you have been so helpful and thanks for the quick response and resolution.

    Just a quick question, is there anyway of being able to return to a specific page number on a partially submitted form when accessing via the ?recordGuid url??

  • Comment author was deleted

    Nov 03, 2014 @ 14:40

    Great so it now functions as it should?

    For your second question don't think there is atm but is easy enough to add (so you can also provide it with a query string param), so will do that and then get a new version out

  • Comment author was deleted

    Nov 03, 2014 @ 14:44

    ow there actually is a way already, just provide ?formstep and it will load it on that specified form step

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 14:45
    Graham Carr
    0

    As mentioned I have only had time to give it a quick test as currently working on another project today but will be able to test it more in full later this week, currently though everything looks to be working as it should. If you are able to add the option to return to a specific page that would be great so thanks in advance for that, that should then cover the majority of my outstanding requirements for my intelligent forms functionality.

  • Graham Carr 277 posts 389 karma points
    Nov 03, 2014 @ 14:47
    Graham Carr
    0

    Oh excellent, even better, will give that a try :)

  • Graham Carr 277 posts 389 karma points
    Nov 06, 2014 @ 11:46
    Graham Carr
    0

    Hi Tim, an additional question?? Is there anyway of knowing what the last page a user was on within the form so that you can return to that page upon re-opening the form?

  • Comment author was deleted

    Nov 06, 2014 @ 12:49

    Think you'll have to write a workflow for that , attach to partially submitted and store the form step against the member

Please Sign in or register to post replies

Write your reply to:

Draft