public static function statusDropdown()
{
// get data if needed
static $dropdown;
$constPrefix = "STATUS_";
if ($dropdown === null) {
// create a reflection class to get constants
$reflClass = new ReflectionClass(get_called_class());
$constants = $reflClass->getConstants();
// check for status constants (e.g., STATUS_ACTIVE)
foreach ($constants as $constantName => $constantValue) {
// add prettified name to dropdown
if (strpos($constantName, $constPrefix) === 0) {
$prettyName = str_replace($constPrefix, "", $constantName);
$prettyName = Inflector::humanize(strtolower($prettyName));
$dropdown[$constantValue] = $prettyName;
}
}
}
return $dropdown;
}