Merge pull request #844 from dogmatic69/form-bug

Adding a check to the object before use
This commit is contained in:
Mark Story 2012-09-14 08:16:40 -07:00
commit 98992e021a

View file

@ -146,7 +146,7 @@ class FormHelper extends AppHelper {
));
} elseif (ClassRegistry::isKeySet($this->defaultModel)) {
$defaultObject = ClassRegistry::getObject($this->defaultModel);
if (in_array($model, array_keys($defaultObject->getAssociated()), true) && isset($defaultObject->{$model})) {
if ($defaultObject && in_array($model, array_keys($defaultObject->getAssociated()), true) && isset($defaultObject->{$model})) {
$object = $defaultObject->{$model};
}
} else {