Specific custom field format (conditional format)

juergen_mueller

DaDaBIK Guru
You are using DaDaBIK version 7.3.3 enterprise, installed on 31.07.2016, the last version of DaDaBIK is 7.3.3 released on 26.07.2016

You are runnning the last release of DaDaBIK

PHP Version: 5.4.45-0+deb7u4

mysql version: 5.5.50-0+deb7u2

Web server: Apache

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/601.6.17 (KHTML, like Gecko) Version/9.1.1 Safari/601.6.17

Hi, Eugenio

I wonder whether it's possible to highlight a field value depending on its content.

In my case I would like to highlight (background color e.g.) a date field (insert_date) where the insert date is not older than let's say a fortnight. Is that possible at all?

Thanks, Jürgen
 

eugenio

Administrator
Staff member
Hello,
if you use custom formatting functions you can basically do what you want, so you can check the date and in case return the value surrounded by a <span style=".....'> </span> that adds the effect you need.

Best,
 
Hi, I am trying to implement exactly the same function, as I have no experience in coding could you please give me a detailed example on how to do it?
Many Thanks
Giuseppe
 

eugenio

Administrator
Staff member
Custom formatting functions are explained here:


you will find a detailed example of code.

Best,
 
Thank you Eugenio this is exactly wahat I was searching for.

Just another small tip...
I added in the custom_formatting_funcions.php the code to make some test, saved it, but in the Form configurator when I start typing the function does not appear...
What could be wrong?

Regards
Giuseppe
 

eugenio

Administrator
Staff member
Does the name of the function start with dadabik_ ?
Do you have tabs or spaces before the work function?
 
this is the content of my custom.formatting.function.php
id_scad is the name of the unique field in the table I want to process.


<?php
function dadabik_format_test($value, $id_scad){
if ($value<1000){
return '<span style="color:red">'.$value.'</span>';
}
elseif $value<100){
return '<span style="color:brown">'.$value.'</span>';
}
else {
return '<span style="color:green">'.$value.'</span>';
}
}
?>

do you see any issue on it?
 
Top