Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Redirect to another form after saving

Questions related to using nuBuilder Forte.
Post Reply
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Redirect to another form after saving

Unread post by marc »

Hi,

I'm looking for a smiliar function like nuReturnNewRecord but to redirect the user to another form, not the same one.

The user would
1. Open Edit Form -> 2. Save -> 3. After Save Event ->
Call a function like nuForm($form_id, "", '', '', '1'); in PHP to open the browse screen with the $form_id.

Thanks for all your ideas.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: Redirect to another form after saving

Unread post by Janusz »

maybe try following
>>> hide standard save button
>>> add your save button
>>> modify form id acc. to your form (and you can paste directly the code belowe)

Code: Select all

function save_AND_go() {nuSaveAction(); setTimeout(function(){nuForm("5cd8079cc7615a0",'','', ''); }, 1000); }
nuHide('nuSaveButton');
nuAddActionButton('my_save_button', 'Save', 'save_AND_go()');
just a basic idea - you probably will need to add some other options like changing color to red, etc.
If you like nuBuilder, please leave a review on SourceForge
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Re: Redirect to another form after saving

Unread post by marc »

This code poses various problems:

If someone uses the options menu or the shortcut key to save
If the is a "no blanks" validation, the redirection takes place but the form entries are not saved
If a nuBeforeSave function is used and return false is set there

The best (?) way to do this would really be to have a PHP function for it.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Redirect to another form after saving

Unread post by admin »

marc,

You could try this in the Form's Javascript section...

Code: Select all

if(nuFormType() == 'edit' && !nuIsNewRecord()){
    nuForm('5d8965c525c4d6f', '');
}
(replace 5d8965c525c4d6f with the Form ID you need)

If the Edit Form is not new (-1) you'll go to a different Browse Form once it is saved.


Steven
marc
Posts: 92
Joined: Mon May 14, 2018 3:26 pm

Re: Redirect to another form after saving

Unread post by marc »

admin wrote:marc,

If the Edit Form is not new (-1) you'll go to a different Browse Form once it is saved.
This now prevents me from reopening the record at all.


1. Open Edit Form -> 2. Save -> 3. After Save Event -> Redirect to another form.

The forwarding should really only happen after saving.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Redirect to another form after saving

Unread post by kev1n »

Marc,

Here's a complete example:

https://github.com/smalos/nuBuilder4-Co ... breadcrumb


But as you wrote in another topic, nuHasBeenSaved() returns a wrong result.


And here comes the fix:

https://github.com/smalos/nuBuilder4-Bu ... n_value.md
Post Reply