Page 1 of 1

nuMessage() / PHP

Posted: Sun Feb 18, 2018 11:44 am
by toms
Hi,

I'd like to display a message with PHP. I thought I could call

Code: Select all

nuMessage("Hello"); 
in the AS event, but the passed parameter o is empty. What am I doing wrong?
nuMessage.PNG

Re: nuMessage() / PHP

Posted: Sun Feb 18, 2018 8:49 pm
by admin
toms,

If you want to set a message with Javascript (which takes an Array of Strings) use...

Code: Select all

nuMessage(['Hello World']) - which takes an Array of Strings.
http://wiki.nubuilder.net/nubuilderfort ... #nuMessage


If you want to set a Message with PHP (which takes a String) use...

Code: Select all

nuDisplayError('Hello World'); - which takes a String.
http://wiki.nubuilder.net/nubuilderfort ... splayError

If nuDisplayError() is called in the Before Save or Before Delete, it will stop the record being Saved or Deleted.

Otherwise, it will just return a message...


Steven

Re: nuMessage() / PHP

Posted: Mon Feb 19, 2018 12:56 am
by toms
Steven,

Actually I just want to show an info message in PHP, nuDisplayError() is not suitable since it will then not save the record.
I was wondering why I could call the js function nuMessage() from php (but, as already mentioned, no parameter is passed).

Re: nuMessage() / PHP

Posted: Mon Feb 19, 2018 10:37 pm
by admin
toms,

If nuDisplayError() is used in After Save or After Delete, a message will now appear.

Please see if this now works for you.

(You'll need the latest from Github.)

Steven

Re: nuMessage() / PHP

Posted: Tue Feb 20, 2018 6:21 am
by toms
Steven,

It works all fine. I just think that the function's name is a bit misleading since, in this case, it shows only an ordinary message and not an error message.

Just as an idea for the (far) future : A function nuDisplayMessage() could be created with different types of messages.

Something like that:
msg3.png
message_types.jpg

Re: nuMessage() / PHP

Posted: Tue Feb 20, 2018 5:53 pm
by admin
toms,

Hopefully, nuDisplayError() isn't so confusing to the developer if they read the wiki.

http://wiki.nubuilder.net/nubuilderfort ... splayError - I updated it yesterday.

If you mean a message might be misleading to a User, then that could be considered the developer's fault.

But the string passed to nuDisplayError can be HTML.

So you could do something like this...

Code: Select all

nuMessage(["<img id='nulogo' width='40px' src='graphics/numessage.png' style='position:absolute;left:2px;top:2px'>","That is now finished!"])
numessage.png and nuerror.png are available in nuBuilder Forte's graphics directory.

Steven

Re: nuMessage() / PHP

Posted: Wed Feb 21, 2018 5:04 pm
by toms
admin wrote:opefully, nuDisplayError() isn't so confusing to the developer if they read the wiki.
I mean if nuDisplayError() is not always intended to display an error message, then the name is misleading. But that's a matter of opinion.

While nuMessage() can be used in Javascript,
I just want to show an info message in PHP
Is there an easy way to call nuMessage() from PHP code? I've tried using echo but without success.

Re: nuMessage() / PHP

Posted: Wed Feb 21, 2018 7:07 pm
by admin
toms,

I don't understand your question.
Is there an easy way to call nuMessage() from PHP code?
nuMessage() is a Javacript function.

Steven

Re: nuMessage() / PHP

Posted: Thu Feb 22, 2018 7:10 am
by toms
My question was:
Is there an easy way to call nuMessage() from PHP code? I've tried using echo but without success.
A possible solution to use nuMessage() in PHP:

Code: Select all

$j = "nuMessage([\"<img id=\'nulogo\' width=\'40px\' src=\'graphics\/numessage.png\' style=\'position:absolute;left:2px;top:2px\'>\",\"That is now finished!\"])";

nuAddJavascript($j);

EDIT: The message is not showing up in AS (PHP) :x

Re: nuMessage() / PHP

Posted: Thu Feb 22, 2018 6:11 pm
by admin
toms,

nuAddJavascript() adds Javascript to a Browse Form or an Edit Form as it loads the Form.

It will only work with Before Save and Before Edit.

http://wiki.nubuilder.net/nubuilderfort ... Javascript

Steven