This topic is locked
[SOLVED]

 Hiding fields

10/7/2014 6:08:23 PM
PHPRunner General questions
C
cyberslugg author

i am in PHP Runner 7.1 and I am trying to hide a couple fields based on the value of a third. I referenced http://www.asprunner.com/forums/topic/17234-hide-certain-columns-for-list-page/
Maybe I need more sleep but... I can not get it to hide when the Status_Code is set as 1. If I remove the if statement then the hide coding works, but I need the if statement.
I have put the following code in the Before Display event on the list and edit pages
if ($data["Status_Code"] == "1")

{

$xt->assign("CurrentStatusCode_fieldheadercolumn",false);

$xt->assign("CurrentStatusCode_fieldcolumn",false);

$xt->assign("SeekingEmploymentFlag_fieldheadercolumn",false);

$xt->assign("SeekingEmploymentFlag_fieldcolumn",false);

}
I'm sure this is simple.... just can't see straight.
Thanks for any help

C
cyberslugg author 10/7/2014

Is it possible that the database value of Status_Code is not being passed at the Before Display stage? Do I need to add a custom sql call in order to load the DB values at this point? using the following coding is not working...
$data = $pageObject->getCurrentRecord();
if ($data["Status_Code"] == 1)

{

$xt->assign("CurrentStatusCode_fieldheadercolumn",false);

$xt->assign("CurrentStatusCode_fieldcolumn",false);

$xt->assign("SeekingEmploymentFlag_fieldheadercolumn",false);

$xt->assign("SeekingEmploymentFlag_fieldcolumn",false);

}

Sergey Kornilov admin 10/7/2014

According to the manual you need to use $values array to access the value of any given field i.e. $values["FieldName"]

http://xlinesoft.com/phprunner/docs/before_display.htm

C
cyberslugg author 10/8/2014

Thanks Romaldus and Sergey. I have been working with those pages, I found and used both in my searching and testing... however I have not had success.
Basically I can not get a positive response... ie if statement = True
I have used
if ($values["Status_Code"] == 1)

if ($values["Status_Code"] == "1")

if ($values["Status_Code"] == '1')

if ($values["Status_Code"] ===1)
And every possible combination I can think of just trying to get a positive statement. The only thing that has worked is the not equals to in the following statement
if ($values["Status_Code"] !==1)
that returns a true for the if statement but that doesn't help me. I have been hitting my head on this so much I might be totally missing something simple.
if I use your format, pasted below, romaldus, with the "not equals" option it always always returns a true, even if I have a 0 in the vote field. If I change the operator to ==, ===, use " or ' I will never get a true return.
if ($values["VOTE"] !== '0')

{

$xt->assign ("save_button", false);

}
when I run echo $values["Status_Code"]; in the before display, I get nothing, i have a echo "testing_this"; beside it which works great... but I see nothing.
Again, i am wondering if for some reason I am not getting actual values assigned from the database in the before display.
I have 2 other options to try, resetting the page and completely wiping the site this is on and reloading the whole thing to see if either of these fix it... apart from that I am stuck
I appreciate the help and any other tips would be great.

G
gudon 10/8/2014

cyberslugg,
You need to specify the event pages that you are trying these codes on, Add, Edit, View or List. For each event page, the arguments ($values, $data) for array of the field values are different. Go to the event page that you are fighting with, read the Description by clicking the "plus" sign. There you will find what argument to use and whether your design is possible or not for PHPRunner to make.
Hope it helps.
Gudon