From 8ec434ed41442ed2a100249e3ea16d615e7c83a9 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Thu, 6 Sep 2018 14:17:53 +0100 Subject: [PATCH] Fix edit form of custom field not linked to optiongroup --- CRM/Custom/Form/Field.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 4391c22ee3..518bd0d7b4 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -324,10 +324,12 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { if ($this->_action == CRM_Core_Action::UPDATE) { $this->freeze('data_type'); - // Before dev/core#155 we didn't set the is_reserved flag properly, which should be handled by the upgrade script... - // but it is still possible that existing installs may have optiongroups linked to custom fields that are marked reserved. - $optionGroupParams['id'] = $this->_values['option_group_id']; - $optionGroupParams['options']['or'] = [["is_reserved", "id"]]; + if (!empty($this->_values['option_group_id'])) { + // Before dev/core#155 we didn't set the is_reserved flag properly, which should be handled by the upgrade script... + // but it is still possible that existing installs may have optiongroups linked to custom fields that are marked reserved. + $optionGroupParams['id'] = $this->_values['option_group_id']; + $optionGroupParams['options']['or'] = [["is_reserved", "id"]]; + } } // Retrieve optiongroups for selection list -- 2.25.1