Skip to content

Commit

Permalink
Merge pull request #21495 from colemanw/fieldsForJoin
Browse files Browse the repository at this point in the history
SearchKit - Exclude custom fields from ON clause selector
  • Loading branch information
eileenmcnaughton authored Sep 19, 2021
2 parents 7aac971 + ba149e2 commit 83e68a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Civi/Api4/Service/Spec/SpecFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static function arrayToField(array $data, $entity) {
$field->setName($data['custom_group_id.name'] . '.' . $data['name']);
}
else {
// Fields belonging to custom entities are treated as normal; type = Field instead of Custom
$field->setType('Field');
$field->setTableName($data['custom_group_id.table_name']);
}
$field->setColumnName($data['column_name']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,10 @@
};

function getFieldsForJoin(joinEntity) {
return {results: ctrl.getAllFields(':name', ['Field', 'Custom'], null, joinEntity)};
return {results: ctrl.getAllFields(':name', ['Field'], null, joinEntity)};
}

// @return {function}
$scope.fieldsForJoin = function(joinEntity) {
if (!fieldsForJoinGetters[joinEntity]) {
fieldsForJoinGetters[joinEntity] = _.wrap(joinEntity, getFieldsForJoin);
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/api/v4/Action/CustomValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testCRUD() {
$expectedResult = [
[
'custom_group' => $group,
'type' => 'Custom',
'type' => 'Field',
'name' => $colorFieldName,
'title' => $colorFieldName,
'entity' => "Custom_$group",
Expand All @@ -97,7 +97,7 @@ public function testCRUD() {
],
[
'custom_group' => $group,
'type' => 'Custom',
'type' => 'Field',
'name' => $multiFieldName,
'title' => $multiFieldName,
'entity' => "Custom_$group",
Expand All @@ -110,7 +110,7 @@ public function testCRUD() {
],
[
'custom_group' => $group,
'type' => 'Custom',
'type' => 'Field',
'name' => $textFieldName,
'title' => $textFieldName,
'entity' => "Custom_$group",
Expand Down

0 comments on commit 83e68a9

Please sign in to comment.