BUGFIX If CTF doesn't have a parent class (set to false), avoid breakages in ComplexTableField::getFieldsFor()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@77140 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-05-19 02:43:55 +00:00 committed by Sam Minnee
parent b6569c5dfd
commit 9b903070a0

View File

@ -475,6 +475,7 @@ JS;
function getFieldsFor($childData) {
// See if our parent class has any many_many relations by this source class
if($this->getParentClass()) {
if($this->sourceID()) {
$parentClass = DataObject::get_by_id($this->getParentClass(), $this->sourceID());
} else {
@ -500,6 +501,7 @@ JS;
$hasManyRelationName = $relation;
}
}
}
// Add the relation value to related records
if(!$childData->ID && $this->getParentClass()) {
@ -510,7 +512,7 @@ JS;
$detailFields = $this->getCustomFieldsFor($childData);
if($hasManyRelationName && $childData->ID) {
if($this->getParentClass() && $hasManyRelationName && $childData->ID) {
$hasManyComponentSet = $parentClass->getComponents($hasManyRelationName);
}