No announcement yet.

Close Add User modal and redirect to another form

  • Filter
  • Time
  • Show
Clear All
new posts

  • Close Add User modal and redirect to another form

    Good afternoon,

    I'm struggling to do what I thought would be a simple redirect but it's not working as I'd expect it to. When I add a user in my application, the Add User form pops up in a Modal view. I then enter all the information necessary, and when complete, want to Save/Insert the record, close the form and then open up a grid where I can add some other information that ties to the new user (I'm pulling their User info into the grid with variables). While the redirect is working, it's redirecting to the grid inside a Modal window which looks horrible. I don't want it in a Modal window because it doesn't fit and looks ugly.

    So how do I have the Add User (or Edit User) form close out completely after the insert and then redirect to a grid to add some other information for the user? What I have now (that keeps opening in Modal) is this: sc_redir('mygrid.php');

    FWIW: For simpler testing, I put this code in the OnAfterUpdate so that I didn't have to keep inserting a full user profile on each test, and then simply made a small change and then saved it:

    echo "<script type='text/javascript'>". "window.close();". "</script>";
    -- Did not close out Add User Modal

    echo "<script>window.parent.tb_remove();</script>";
    -- Did not close out Add User Modal

    -- Spun and didn't do anything

    ​-- Spun and didn't do anything

    Any idea on how to force the Modal window completely shut and then redirect to my grid?

    Thanks very much,


  • #2
    Hi Mark,

    You could try the other way around: Start in a grid with user information, i.e. columns for the basic one and the extra to be added. Use Programming->Links to create a link from the grid to the add user form. You can add key relation in the link definition and also specify that a "New" button is to be part of the grid, so that you can open the add user form from the grid.

    Here is a link to a tutorial describing how the link is created:

    I think that the above way is better than trying to redirect from modal forms. However, if you wish to redirect from the user form (probably the one generated from ScriptCase?), you could change the link calling the add user form so that it is not run modal. This will then make it possible to redirect without it looking ugly.
    Last edited by Orion; 06-24-2016, 03:03 AM.
    Best regards,



    • #3
      I agree with Orion that modal forms should not be used in this context. For me modal forms are nice for lookups, but not for inserting data. That's why we have changed the behaviour to regular forms. Then you don't have this issue. You can easily change this behaviour in the links section.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development /


      • #4
        Hi Orion and aducom,

        Thanks so much for the feedback and the tips although Orion, your link does not work =( Either way, it pointed me in the right direction and changing the format of the form being called in the links is exactly what I was looking for (Orion, yes, it's the one Scriptcase automatically builds in their Security Wizard). I still find it amazing how we sometimes get so wrapped up in the task at hand, that we don't see the other options which are often even better solutions that what one is trying to come up with. Perfect, thanks so much guys! Have a great weekend.



        • #5
          in your onvalidatesucess event use this at the very end

          PHP Code:
          sc_commit(); // save the changes (inserts the data)
          sc_redir"mygridappname" "_parent"); 
          That should do it.



          • #6
            kafecadm, not from a modal form.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development