Skip to content
This repository
Browse code

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
Carl Sutton authored September 14, 2012

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  lib/Cake/View/Helper/FormHelper.php
2  lib/Cake/View/Helper/FormHelper.php
@@ -146,7 +146,7 @@ protected function _getModel($model) {
146 146
 			));
147 147
 		} elseif (ClassRegistry::isKeySet($this->defaultModel)) {
148 148
 			$defaultObject = ClassRegistry::getObject($this->defaultModel);
149  
-			if (in_array($model, array_keys($defaultObject->getAssociated()), true) && isset($defaultObject->{$model})) {
  149
+			if ($defaultObject && in_array($model, array_keys($defaultObject->getAssociated()), true) && isset($defaultObject->{$model})) {
150 150
 				$object = $defaultObject->{$model};
151 151
 			}
152 152
 		} else {

0 notes on commit 6f3e6c1

Please sign in to comment.
Something went wrong with that request. Please try again.