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

sc_exit©;
– Spun and didn’t do anything

sc_exit();
​-- 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,

Mark.

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:
www.scriptcase.net/scriptcase-samples/tutoriais/grid/grid16.php

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.

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.

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.

Mark.

in your onvalidatesucess event use this at the very end


sc_commit(); // save the changes (inserts the data)
sc_redir( "mygridappname" , "_parent");

That should do it.

Regards

@kafecadm, not from a modal form.

@kafecadm your code is correct, but parameter sequence is wrong. In sc_redir(), first parameter is the target, second parameter is for sending some values. Thus, instead of your code, use this one -

sc_commit(); // save the changes (inserts the data)
sc_redir( “mygridappname”,"", “_parent”);

This will work.

Thanks
Lokesh Patel
Igetis Solutions
Pune, INDIA