เพียงแค่ใส่ฟังก์ชั่นนี้ใน app/app_controller.php
<?php
class AppController extends Controller {
function beforeRender() {
foreach ($this->modelNames as $model) {
foreach ($this->$model->_schema as $var => $field) {
if (strpos($field['type'], 'enum') === FALSE) continue;
preg_match_all("/\'([^\']+)\'/", $field['type'], $strEnum);
if (is_array($strEnum[1])) {
$varName = Inflector::variable(Inflector::pluralize($var));
$options = array();
foreach ($strEnum[1] as $value) {
$options[$value] = __($value, true);
}
$this->set($varName, $options);
}
}
}
}
}
?>
ไม่มีความเห็น