Skip to content

Commit

Permalink
Allow custom fields of type Select to be defined without specifying a…
Browse files Browse the repository at this point in the history
…n option group (so they can be populated dynamically using hook_civicrm_fieldOptions
  • Loading branch information
mattwire committed Jul 23, 2018
1 parent 1627fe6 commit 6c5d3fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ public function getOptions($context = NULL) {
$this->find(TRUE);
}

// This will hold the list of options in format key => label
$options = [];

if (!empty($this->option_group_id)) {
$options = CRM_Core_OptionGroup::valuesByID(
$this->option_group_id,
Expand All @@ -421,9 +424,6 @@ public function getOptions($context = NULL) {
elseif ($this->data_type === 'Boolean') {
$options = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean();
}
else {
return FALSE;
}
CRM_Utils_Hook::customFieldOptions($this->id, $options, FALSE);
CRM_Utils_Hook::fieldOptions($this->getEntity(), "custom_{$this->id}", $options, array('context' => $context));
return $options;
Expand Down

0 comments on commit 6c5d3fc

Please sign in to comment.