Colors not changed in child records
Posted: 2014-03-11 20:09
I'm trying to implement a color change of a field for certain data using this forum thread. It works great for TV as a parent but in the child view the colors are not changed.
In the tablename_init hook, I have my workorders.status text changing color based on what the data is (if workorder.status = "Complete", font-color="red"). I also have a location table, and related child workorder records are displayed under each location record. When viewing the workorder records as children, the color does not take effect.
Examples-
Working in TV:

Not working as child ("New" should be green):

Here is the code I'm using in hooks/workorders.php:
Where else must I place the code to color the records the same across all views?
In the tablename_init hook, I have my workorders.status text changing color based on what the data is (if workorder.status = "Complete", font-color="red"). I also have a location table, and related child workorder records are displayed under each location record. When viewing the workorder records as children, the color does not take effect.
Examples-
Working in TV:

Not working as child ("New" should be green):

Here is the code I'm using in hooks/workorders.php:
Code: Select all
function workorders_init(&$options, $memberInfo, &$args){
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`workorders`.`status`'){
$options->QueryFieldsTV['IF(`workorders`.`status`=\'New\', \'<b style="color: green;">New</b>\', IF(`workorders`.`status`=\'Complete\', \'<b style="color: red;">Complete!</b>\', `workorders`.`status`))']=$caption;
}
else
{
$options->QueryFieldsTV[$field]=$caption;
}
}