Warning: Invalid argument supplied for foreach() in /project/cake/libs/controller/controller.php on line 724

Error would occur when the associated table did not contain any records

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3706 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-10-18 12:23:28 +00:00
parent b64e19073b
commit e6e50dc936

View file

@ -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;
}