Page 1 of 1

Redirect to another form after saving

Posted: Thu Sep 17, 2020 8:53 pm
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.

Re: Redirect to another form after saving

Posted: Thu Sep 17, 2020 10:47 pm
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.

Re: Redirect to another form after saving

Posted: Fri Sep 18, 2020 5:03 am
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.

Re: Redirect to another form after saving

Posted: Fri Sep 18, 2020 9:15 am
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

Re: Redirect to another form after saving

Posted: Tue Sep 22, 2020 6:04 am
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.

Re: Redirect to another form after saving

Posted: Wed Sep 23, 2020 8:19 am
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