Hello!
According to https://wiki.nubuilder.cloud/index.php?title=Functions PHP BeforeSave event can stop saving process by value "No" (as on scheme). What and how PHP code should return for "YES" and "NO' values. I can't find any example in docs.
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
PHP BeforeSave return value Topic is solved
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: PHP BeforeSave return value
Hi,
The diagram you are referring to only illustrates the possible paths that the "BeforeSave" event can take (continue saving or abort saving).
You can use the nuDisplayError() function to display an error message to the user to abort saving and display a message.
Example:
The diagram you are referring to only illustrates the possible paths that the "BeforeSave" event can take (continue saving or abort saving).
You can use the nuDisplayError() function to display an error message to the user to abort saving and display a message.
Example:
Code: Select all
// Some validation code to check if the data is valid
if (/* data is not valid */) {
// Display an error message and stop the save process
nuDisplayError('The data you entered is not valid.');
} else {
// Allow the save to continue...
}
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: PHP BeforeSave return value
One approach that comes to mind is to promptly remove the message by declaring nuOnMessage() in the form's Custom Code:
And in BS
Code: Select all
function nuOnMessage(msgDiv, errors) {
if (errors == 'do_not_show_the_error') {
msgDiv.remove();
nuAbortSave();
}
}
Code: Select all
nuDisplayError('do_not_show_the_error');