Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding a check to the object before use

For some reason that I have not been able to figure out yet the object is
returned as null.  This is causing some exceptions when trying to access
properties that dont exist.

FatalErrorException: "Call to a member function getAssociated() on a non-object"

Test still pass with the added check.
  • Loading branch information...
commit 6f3e6c10a146ee431bf6deeed33b590a036ee6f2 1 parent 1fe7913
@dogmatic69 dogmatic69 authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/Cake/View/Helper/FormHelper.php
View
2  lib/Cake/View/Helper/FormHelper.php
@@ -146,7 +146,7 @@ protected function _getModel($model) {
));
} 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 {
Please sign in to comment.
Something went wrong with that request. Please try again.