Adding fix for #2473

Fixed undefined variable notice in Form::inputs()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4889 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-04-27 20:16:38 +00:00
parent 99b0ee21a8
commit 30498981a7
3 changed files with 36 additions and 18 deletions

View file

@ -105,6 +105,15 @@ class ClassRegistry {
}
return false;
}
/**
* Get all keys from the regisrty.
*
* @return array
*/
function keys() {
$_this =& ClassRegistry::getInstance();
return array_keys($_this->__objects);
}
/**
* Return object which corresponds to given key.
*
@ -142,6 +151,15 @@ class ClassRegistry {
$_this->__map[$key] = $name;
}
}
/**
* Get all keys from the map in the regisrty.
*
* @return array
*/
function mapKeys() {
$_this =& ClassRegistry::getInstance();
return array_keys($_this->__map);
}
/**
* Return the name of a class in the registry.
*
@ -155,4 +173,4 @@ class ClassRegistry {
}
}
}
?>
?>

View file

@ -598,11 +598,13 @@ class Controller extends Object {
$this->__viewClass =& new $viewClass($this);
if (!empty($this->modelNames)) {
$count = count($this->modelNames);
for ($i = 0; $i < $count; $i++) {
$model = $this->modelNames[$i];
if (!empty($this->{$model}->validationErrors)) {
$this->__viewClass->validationErrors[$model] = &$this->{$model}->validationErrors;
$models =& ClassRegistry::keys();
foreach($models as $currentModel) {
if (ClassRegistry::isKeySet($currentModel)) {
$currentObject =& ClassRegistry::getObject($currentModel);
if(is_a($currentObject, 'Model') && !empty($currentObject->validationErrors)) {
$this->__viewClass->validationErrors[Inflector::camelize($currentModel)] =& $currentObject->validationErrors;
}
}
}
}

View file

@ -101,19 +101,14 @@ class FormHelper extends AppHelper {
if (ClassRegistry::isKeySet($model)) {
$object =& ClassRegistry::getObject($model);
if(!empty($object->validationErrors)) {
$this->validationErrors[$model] = $object->validationErrors;
}
}
foreach($object->__associations as $type) {
foreach($object->{$type} as $assoc => $value) {
if (is_array($value) && isset($value['className']) && low($value['className']) !== low($object->name) && ClassRegistry::isKeySet($value['className'])) {
$innerObject =& ClassRegistry::getObject($value['className']);
if(!empty($innerObject->validationErrors)) {
$this->validationErrors[$innerObject->name] = $innerObject->validationErrors;
}
}
$models =& ClassRegistry::keys();
foreach($models as $currentModel) {
if (ClassRegistry::isKeySet($currentModel)) {
$currentObject =& ClassRegistry::getObject($currentModel);
if(is_a($currentObject, 'Model') && !empty($currentObject->validationErrors)) {
$this->validationErrors[Inflector::camelize($currentModel)] =& $currentObject->validationErrors;
}
}
}
@ -331,11 +326,14 @@ class FormHelper extends AppHelper {
* @return output
*/
function inputs($fields = null, $blacklist = null) {
$fieldset = null;
if(!is_array($fields)) {
$fieldset = $fields;
} else if(isset($fields['fieldset'])) {
$fieldset = $fields['fieldset'];
unset($fields['fieldset']);
} else {
$fieldset = true;
}
if($fieldset === true) {