Forums

DB Recordloader Empty Result not triggered

tshirley 19 May, 2014
Hello,

One more question - I really keep hoping it is the last.

I have a form with a DBRecordloader action - it has a WHERE clause with two fields tested:

Field1 = 'value1' AND Field2 - 'value2'

It works well when records are found, but when no matching record is returned it does not trigger the "On Empty Result" event. In fact it bypasses this and presents a blank form to the user. The problem with this is that if the user adds some data in the empty form and hits Submit, a new record will be created. While I can manage this, it would be better to have the Empty Result triggered so that I can present an error message and a Showstopper (which is what I was trying to do).

What are the criteria for triggering a On Empty Result?

Cheers

Tim
GreyHead 19 May, 2014
Hi Tim,

Looking at the code I think it should be triggered when the $data array is empty . . . but I suspect there may be a bug and the On Empty Result and On Empty/No Param Passed events are reversed. Here's the code:
		//check the result
			$request_val = $req_param;//JRequest::getVar($params->get('request_param', ''));
			if(!empty($data)){
				$this->events['found'] = 1;
			}else if(empty($request_val)){
				$this->events['nodata'] = 1;
			}else if(empty($data)){
				$this->events['notfound'] = 1;
			}else{
			
			}

Two things to test, one is to add a debugger and check that the $data array actually is empty; two to try the 'other' event and see if that works . . .

Bob
tshirley 19 May, 2014
Thanks Bob,

Changing to the other event solved the problem. Hopefully I'll stop asking silly questions now, but don't bet on it!

Cheers

Tim
This topic is locked and no more replies can be posted.