How can I show an error condition in AppGini?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
compusoft
Posts: 18
Joined: 2023-05-05 09:14

How can I show an error condition in AppGini?

Post by compusoft » 2023-06-04 02:00

Hi

My problem has a more easy solution not involving javascript validation code.
In /hooks/reservas.php

Code: Select all

function Reservas_before_insert(&$data, $memberInfo, &$args) {
		
		/* PHP VALIDATE SITE & DATE BEFORE INSERT THE RECORD
		$idSitio = intval($data['Sitio']);	
		$enFecha = $data['Fecha'];
		
		$nSitios = sqlValue("SELECT COUNT(*) FROM Reservas WHERE Sitio ='{$idSitio}' AND Fecha='{$enFecha}'");
				
		if ($nSitios > 0) {
			error_message('SITE RESERVED FOR THIS DATE!', false);
			return false;
		}
		return TRUE;
	}
Works fine, but the message "SITE RESERVED ..." never shows. Instead ...
noError.jpg
noError.jpg (26.61 KiB) Viewed 1178 times
error_message() is an AppGini function, as far I know.
How can I show this warning to the user

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: How can I show an error condition in AppGini?

Post by a.gneady » 2023-06-04 10:41

Try this:

Code: Select all

$args['error_message'] = 'SITE RESERVED FOR THIS DATE!';
This can be used as of AppGini 5.90 and above. See https://bigprof.com/appgini/help/advanc ... ore_insert
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

compusoft
Posts: 18
Joined: 2023-05-05 09:14

Re: How can I show an error condition in AppGini?

Post by compusoft » 2023-06-05 16:47

It worked fine! Thanks a lot!

Is there a AppGini function to show a modal window to the user and have them press an OK button?
Or should it be done as a separate html page?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How can I show an error condition in AppGini?

Post by jsetzer » 2023-06-05 16:49

confirm() Javascript function is the easiest way. And it should be compatible with all browsers and OS's.

https://www.w3schools.com/jsref/met_win_confirm.asp
Re: How can I show an error condition in AppGini?
PS: for completely different questions please start a new thread with a different subject. This will help others searching for topics and finding already answered questions.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply