I have an Add page which contains address fields, the format and content of the first 2 address lines varies accordingly to the type of accommodation; House, Flat, Hotel, Hostel NFA (no fixed abode). In the JSonload event I have a SELECT CASE on the accommodation type to hide or show the relevant fields and alter the field labels. This is working perfectly.
I've run into an issue by adding duplicate checking in the Before record added event that causes the add page to be redisplayed with error text in $message. I can't find a way to get the jsonload event to hide/show the correct fields. The code below is simplified - in reality I'd need a bit more.
Before Display code: I intended this code to provide the jsonload event whether to hide or show the fields.
// set the session variable if its not defined yet - ie on the first display of the add page only
if (!defined($_SESSION["Hide_addr"]) ){
$_SESSION["Hide_addr"] = true;}
// set proxy variable to HIDE or SHOW - could be true or false but this is easy to detect and debug
if ($_SESSION["Hide_addr"]){
$pageObject->setProxyValue("actype", "HIDE");}
else {
$pageObject->setProxyValue("actype", "SHOW");}
jsonload event code
alert ("Accom " + proxy['actype']);
if (proxy['actype']=="HIDE") {
pageObj.hideField('NumLbl'); pageObj.hideField('NumData');
pageObj.hideField('BldgLbl'); pageObj.hideField('BldgData');
pageObj.hideField('street2'); pageObj.hideField('area');
pageObj.hideField('town'); pageObj.hideField('postcode');}
Before Record added event
// check for NFA and HIDE address fields
if ($values['accom_type'] == "NFA") {
$_SESSION["Hide_addr"] = true;}
else {
$_SESSION["Hide_addr"] = false;}
When the Add page is first displayed the address fields are correctly hidden and they appear dynamically when the Accommodation type is input. But when the add page is redisplayed with the error text the proxy value is always HIDE its never SHOW even though the session variable has been changed.
I've tried a number of other coding solutions which haven't worked but I feel this should work. The alert in the jsonload always displays HIDE so my conclusion is that the proxy values set in the Before record added aren't available to the jsonload and that the before display code is only executed once before the first display of the page.
Does anyone known what the control flow is between events? ie does Before Display always get invoked before the add page is displayed or only before the first display of the Add page.
Thanks in advance.
I've run into an issue by adding duplicate checking in the Before record added event that causes the add page to be redisplayed with error text in $message. I can't find a way to get the jsonload event to hide/show the correct fields. The code below is simplified - in reality I'd need a bit more.
Before Display code: I intended this code to provide the jsonload event whether to hide or show the fields.
// set the session variable if its not defined yet - ie on the first display of the add page only
if (!defined($_SESSION["Hide_addr"]) ){
$_SESSION["Hide_addr"] = true;}
// set proxy variable to HIDE or SHOW - could be true or false but this is easy to detect and debug
if ($_SESSION["Hide_addr"]){
$pageObject->setProxyValue("actype", "HIDE");}
else {
$pageObject->setProxyValue("actype", "SHOW");}
jsonload event code
alert ("Accom " + proxy['actype']);
if (proxy['actype']=="HIDE") {
pageObj.hideField('NumLbl'); pageObj.hideField('NumData');
pageObj.hideField('BldgLbl'); pageObj.hideField('BldgData');
pageObj.hideField('street2'); pageObj.hideField('area');
pageObj.hideField('town'); pageObj.hideField('postcode');}
Before Record added event
// check for NFA and HIDE address fields
if ($values['accom_type'] == "NFA") {
$_SESSION["Hide_addr"] = true;}
else {
$_SESSION["Hide_addr"] = false;}
When the Add page is first displayed the address fields are correctly hidden and they appear dynamically when the Accommodation type is input. But when the add page is redisplayed with the error text the proxy value is always HIDE its never SHOW even though the session variable has been changed.
I've tried a number of other coding solutions which haven't worked but I feel this should work. The alert in the jsonload always displays HIDE so my conclusion is that the proxy values set in the Before record added aren't available to the jsonload and that the before display code is only executed once before the first display of the page.
Does anyone known what the control flow is between events? ie does Before Display always get invoked before the add page is displayed or only before the first display of the Add page.
Thanks in advance.