From 5830940de6f09d994c295703d3447103b930a15e Mon Sep 17 00:00:00 2001 From: Michael McAndrew Date: Thu, 24 May 2018 13:33:33 +0100 Subject: [PATCH 1/2] dev/core#140 add missing pseudoconstant for option_group_id in CustomField.xml --- CRM/Core/DAO/CustomField.php | 7 ++++++- xml/schema/Core/CustomField.xml | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Core/DAO/CustomField.php b/CRM/Core/DAO/CustomField.php index 1f48b8858fb3..24b86133fe26 100644 --- a/CRM/Core/DAO/CustomField.php +++ b/CRM/Core/DAO/CustomField.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/CustomField.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:dcb494bf3990ce63b66ef13ee47a2d15) + * (GenCodeChecksum:7f096c92af68ef9564675e3d708fbbe1) */ /** @@ -594,6 +594,11 @@ public static function &fields() { 'entity' => 'CustomField', 'bao' => 'CRM_Core_BAO_CustomField', 'localizable' => 0, + 'pseudoconstant' => [ + 'table' => 'civicrm_option_group', + 'keyColumn' => 'id', + 'labelColumn' => 'title', + ] ], 'filter' => [ 'name' => 'filter', diff --git a/xml/schema/Core/CustomField.xml b/xml/schema/Core/CustomField.xml index 0effe4046dbe..8d81309544f2 100644 --- a/xml/schema/Core/CustomField.xml +++ b/xml/schema/Core/CustomField.xml @@ -262,6 +262,11 @@ Field Option Group For elements with options, the option group id that is used 1.4 + + civicrm_option_group
+ id + title +
filter From f93514f89f92717a08134f830a9b949584adf1c8 Mon Sep 17 00:00:00 2001 From: Michael McAndrew Date: Thu, 24 May 2018 14:08:40 +0100 Subject: [PATCH 2/2] test adding option_group_id by name --- tests/phpunit/api/v3/CustomFieldTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 76a14abcb3aa..9419be414885 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -555,6 +555,20 @@ public function testUpdateCustomField() { $this->customGroupDelete($customGroup['id']); } + public function testCustomFieldCreateWithOptionGroupName() { + $customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_custom_group')); + $params = array( + 'custom_group_id' => $customGroup['id'], + 'name' => 'Activity type', + 'label' => 'Activity type', + 'data_type' => 'String', + 'html_type' => 'Select', + 'option_group_id' => 'activity_type', + ); + $result = $this->callAPISuccess('CustomField', 'create', $params); + } + + /** * @param $getFieldsResult *