BUGFIX Stricter checking that a relation exists on ComplexTableField::saveComplexTableField()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@106755 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-06-21 01:58:33 +00:00 committed by Sam Minnee
parent 3dc526c00f
commit b999ca4c72

View File

@ -650,16 +650,16 @@ JS;
if(isset($data['ctf']['manyManyRelation'])) {
$parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
$relationName = $data['ctf']['manyManyRelation'];
$componentSet = $parentRecord->getManyManyComponents($relationName);
$componentSet->add($childData);
$componentSet = $parentRecord ? $parentRecord->getManyManyComponents($relationName) : null;
if($componentSet) $componentSet->add($childData);
}
if(isset($data['ctf']['hasManyRelation'])) {
$parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
$relationName = $data['ctf']['hasManyRelation'];
$componentSet = $parentRecord->getComponents($relationName);
$componentSet->add($childData);
$componentSet = $parentRecord ? $parentRecord->getComponents($relationName) : null;
if($componentSet) $componentSet->add($childData);
}
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;