X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FForm%2FOptions.php;h=ab4cbedc2fd55231ef2ee6d9ab8587711778a6da;hb=4b377f08d60be46ff3f7e28b6b9e5511b6ddde56;hp=4afd0fbf706f4c354786c9902c2ae2056dc31fb1;hpb=4080069b01751c39b4dfdb61c887528323c71d36;p=civicrm-core.git diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index 4afd0fbf70..ab4cbedc2f 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -113,7 +113,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { // Default weight & value $fieldValues = ['option_group_id' => $this->_gid]; foreach (['weight', 'value'] as $field) { - if (empty($defaults[$field])) { + if (!isset($defaults[$field]) || $defaults[$field] === '') { $defaults[$field] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, $field); } } @@ -147,6 +147,10 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { return; } + $optionGroup = \Civi\Api4\OptionGroup::get(FALSE) + ->addWhere('id', '=', $this->_gid) + ->execute()->first(); + $this->applyFilter('__ALL__', 'trim'); $isReserved = FALSE; @@ -174,11 +178,12 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { ['CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'value', $this->_domainSpecific] ); } - else { + + // Add icon & color if this option group supports it. + if ($optionGroup['option_value_fields'] && in_array('icon', $optionGroup['option_value_fields'])) { $this->add('text', 'icon', ts('Icon'), ['class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE]); } - - if (in_array($this->_gName, ['activity_status', 'case_status'])) { + if ($optionGroup['option_value_fields'] && in_array('color', $optionGroup['option_value_fields'])) { $this->add('color', 'color', ts('Color')); } @@ -269,8 +274,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { // If CiviCase enabled AND "Add" mode OR "edit" mode for non-reserved activities, only allow user to pick Core or CiviCase component. // FIXME: Each component should define whether adding new activity types is allowed. - $config = CRM_Core_Config::singleton(); - if ($this->_gName == 'activity_type' && in_array("CiviCase", $config->enableComponents) && + if ($this->_gName == 'activity_type' && CRM_Core_Component::isEnabled("CiviCase") && (($this->_action & CRM_Core_Action::ADD) || !$isReserved) ) { $caseID = CRM_Core_Component::getComponentID('CiviCase');