From 6f3e6c10a146ee431bf6deeed33b590a036ee6f2 Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Fri, 14 Sep 2012 14:54:10 +0100 Subject: [PATCH] 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. --- lib/Cake/View/Helper/FormHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index a1066a15d..4ff2d9a20 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -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 {