This topic is locked

pageObj.showField("photo");

6/15/2020 3:40:52 PM
PHPRunner General questions
M
mhollibush author

Goal:

Hide all empty fields on the view page except the "photo" field.
View Record Settings:

Hide empty fields - checked
JavaScript OnLoad event:



pageObj.showField("photo");


photo custom view:



if (empty($data["photo"])) {

$value ="<img src='images/no_pic.png'>";

}

else {

$value ="<img src='". $data["thumbpic"] ."'>";

}


doesn't show the photo field....
If I uncheck the "hide empty fields" - the custom view works, but also displays all the other empty fields.
How can I get this to work without making custom views on all the fields on the page?

Sergey Kornilov admin 6/15/2020

'Hide empty fields' kicks in before 'View as' Custom so your code is not relevant.
What you can do is to move your logic to SQL query. Check MySQL's IF() function:

https://www.mysqltutorial.org/mysql-if-function.aspx/