Skip to content

Commit

Permalink
Follow on to #12718 - Display all non-reserved option groups on updat…
Browse files Browse the repository at this point in the history
…e, making sure the existing one is selected.
  • Loading branch information
mattwire committed Aug 25, 2018
1 parent 5bc1d29 commit 064d868
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions CRM/Custom/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,26 +315,22 @@ public function buildQuickForm() {
$this->add('checkbox', 'in_selector', ts('Display in Table?'));
}

if ($this->_action == CRM_Core_Action::UPDATE) {
$this->freeze('data_type');
}
$optionGroupParams = [
'is_reserved' => 0,
'is_active' => 1,
'options' => ['limit' => 0, 'sort' => "title ASC"],
'return' => ['title'],
];

if ($this->_action == CRM_Core_Action::UPDATE) {
$optionGroupParams = [
'id' => $this->_values['option_group_id'],
'return' => ['title'],
];
}
else {
$optionGroupParams = [
'is_reserved' => 0,
'is_active' => 1,
'options' => ['limit' => 0, 'sort' => "title ASC"],
'return' => ['title'],
];
$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"]];
}

// Get all custom (is_reserved=0) option groups
// Retrieve optiongroups for selection list
$optionGroupMetadata = civicrm_api3('OptionGroup', 'get', $optionGroupParams);

// OptionGroup selection
Expand Down

0 comments on commit 064d868

Please sign in to comment.