mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
b64e19073b
commit
e6e50dc936
1 changed files with 7 additions and 6 deletions
|
@ -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,6 +718,7 @@ class Controller extends Object {
|
|||
$otherModel->recursive = 0;
|
||||
$rec = $otherModel->findAll();
|
||||
|
||||
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])) {
|
||||
|
@ -728,6 +727,7 @@ class Controller extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
|
||||
}
|
||||
} else {
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue