From c706dbdcc193540d7b0bbb09cc250a2e7a1b22f0 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 14 Aug 2008 08:19:02 +0000 Subject: [PATCH] BUGFIX Fixed TableListField->Link() to allow for instanciation without a form/controller (e.g. for unit tests) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60757 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TableListField.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/forms/TableListField.php b/forms/TableListField.php index 6b592489b..fe2675f6b 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -1226,8 +1226,14 @@ class TableListField_Item extends ViewableData { } function Link() { - return Controller::join_links($this->parent->Link() . "item/" . $this->item->ID); - } + if($this->parent->getForm()) { + return Controller::join_links($this->parent->Link() . "item/" . $this->item->ID); + } else { + // allow for instanciation of this FormField outside of a controller/form + // context (e.g. for unit tests) + return false; + } + } function BaseLink() { user_error("TableListField_Item::BaseLink() deprecated, use Link() instead", E_USER_NOTICE);