diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index f00de707b..d42b422e3 100755 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -187,12 +187,19 @@ class ComplexTableField extends TableListField { */ function sourceFilter() { $sourceFilter = parent::sourceFilter(); + if($this->relationAutoSetting && $this->getParentClass() && ($filterKey = $this->getParentIdName($this->getParentClass(), $this->sourceClass())) && ($filterValue = $this->sourceID()) ) { $newFilter = "`$filterKey` = '" . Convert::raw2sql($filterValue) . "'"; + + if($sourceFilter && is_array($sourceFilter)) { + // Note that the brackets below are taken into account when building this + $sourceFilter = implode(") AND (", $sourceFilter); + } + $sourceFilter = $sourceFilter ? "($sourceFilter) AND ($newFilter)" : $newFilter; } return $sourceFilter; diff --git a/forms/TableListField.php b/forms/TableListField.php index b16a96896..7721ed0ea 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -926,7 +926,7 @@ JS } } - HTTP::sendFileToBrowser($fileData, $fileName); + return HTTPRequest::send_file($fileData, $fileName); } else { user_error("No records found", E_USER_ERROR); }