CakePHP Custom Global Function -
There are several database fields called "active" on which I am working, which is a boolean, though "1 Instead of displaying "0" or "0", I would say it "yes" or "no".
I have the following functions:
function activatedFindilyName ($ status) {if ($ position == 1) {return "yes"; } Other {return "no"; }}
However, I am unsure why should I put this global function? Will this be the app_model.php file? In addition, how do I implement "formatting"?
You should leave the data until you need to display it coming from the database This means that the scene is the right place to change it. I just want to go to a simple:
$ model ['model'] ['bool'] echo? "Not yes";
But if you need the rules to make it more complicated, which you do not want to repeat every time, create custom helper.
You define a global function in bootstrap.php
, but I do not recommend it.
Comments
Post a Comment