diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 260d05e6e..d6d149ff9 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -624,7 +624,6 @@ class Controller extends Object { $model = $this->modelClass; $modelKey = $this->modelKey; $table = $this->{$model}->table; - //$association = array_search($table, $this->{$model}->alias); $objRegistryModel =& ClassRegistry::getObject($modelKey); foreach($objRegistryModel->_tableInfo as $tables) { @@ -638,7 +637,6 @@ class Controller extends Object { } $fkNames = $this->{$model}->keyToTable[$tabl['name']]; $fieldNames[$tabl['name']]['table'] = $fkNames[0]; - //$association = array_search($fieldNames[$tabl['name']]['table'], $this->{$model}->alias); $fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($niceName); $fieldNames[$tabl['name']]['model'] = $fkNames[1]; $fieldNames[$tabl['name']]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']]; @@ -720,10 +718,12 @@ class Controller extends Object { $otherModel->recursive = 0; $rec = $otherModel->findAll(); - foreach($rec as $pass) { - foreach($pass as $key => $value) { - if ($key == $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']] && isset($value[$otherModel->primaryKey]) && isset($value[$otherDisplayField])) { - $fieldNames[$tabl['name']]['options'][$value[$otherModel->primaryKey]] = $value[$otherDisplayField]; + if(!empty($rec)) { + foreach($rec as $pass) { + foreach($pass as $key => $value) { + if ($key == $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']] && isset($value[$otherModel->primaryKey]) && isset($value[$otherDisplayField])) { + $fieldNames[$tabl['name']]['options'][$value[$otherModel->primaryKey]] = $value[$otherDisplayField]; + } } } } @@ -750,6 +750,7 @@ class Controller extends Object { case "date": case "datetime": case "time": + case "year": if (0 != strncmp("created", $tabl['name'], 7) && 0 != strncmp("modified", $tabl['name'], 8)) { $fieldNames[$tabl['name']]['type'] = $type; }