Adding Controller::_selectedArray().

Changed Bake to use _selectedArray instead of _ _selectedArray()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3742 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-10-26 03:08:53 +00:00
parent 79a8944ba4
commit 12a6df23ef
2 changed files with 18 additions and 1 deletions

View file

@ -1098,6 +1098,23 @@ class Controller extends Object {
function _scaffoldError($method) {
return false;
}
/**
* Enter description here...
*
* @param unknown_type $data
* @param unknown_type $key
* @return unknown
*/
function _selectedArray($data, $key = 'id') {
$array = array();
if(!empty($data)) {
foreach($data as $var) {
$array[$var[$key]] = $var[$key];
}
}
return $array;
}
}
?>

View file

@ -1414,7 +1414,7 @@ class Bake {
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
$actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n";
$actions .= "\t\t\tif(empty(\$this->data['{$associationName}']['{$associationName}'])) { \$this->data['{$associationName}']['{$associationName}'] = null; }\n";
$actions .= "\t\t\t\$this->set('selected_{$otherPluralName}', \$this->__selectedArray(\$this->data['{$associationName}']['{$associationName}']));\n";
$actions .= "\t\t\t\$this->set('selected_{$otherPluralName}', \$this->_selectedArray(\$this->data['{$associationName}']['{$associationName}']));\n";
}
}
foreach($modelObj->belongsTo as $associationName => $relation) {