當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_BAO_OptionValue::getOptionValuesAssocArray方法代碼示例

本文整理匯總了PHP中CRM_Core_BAO_OptionValue::getOptionValuesAssocArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_BAO_OptionValue::getOptionValuesAssocArray方法的具體用法?PHP CRM_Core_BAO_OptionValue::getOptionValuesAssocArray怎麽用?PHP CRM_Core_BAO_OptionValue::getOptionValuesAssocArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_BAO_OptionValue的用法示例。


在下文中一共展示了CRM_Core_BAO_OptionValue::getOptionValuesAssocArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: hrui_civicrm_buildForm

function hrui_civicrm_buildForm($formName, &$form)
{
    CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.hrui', 'css/hrui.css')->addScriptFile('org.civicrm.hrui', 'js/hrui.js');
    if ($form instanceof CRM_Contact_Form_Contact) {
        CRM_Core_Resources::singleton()->addSetting(array('formName' => 'contactForm'));
        //HR-358 - Set default values
        //set default value to phone location and type
        $locationId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', 'Main', 'id', 'name');
        $result = civicrm_api3('LocationType', 'create', array('id' => $locationId, 'is_default' => 1, 'is_active' => 1));
        if ($form->elementExists('phone[2][phone_type_id]') && $form->elementExists('phone[2][phone_type_id]')) {
            $phoneType = $form->getElement('phone[2][phone_type_id]');
            $phoneValue = CRM_Core_OptionGroup::values('phone_type');
            $phoneKey = CRM_Utils_Array::key('Mobile', $phoneValue);
            $phoneType->setSelected($phoneKey);
            $phoneLocation = $form->getElement('phone[2][location_type_id]');
            $phoneLocation->setSelected($locationId);
        }
    }
    $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'type_20130502144049', 'id', 'name');
    //HR-355 -- Add Government ID
    if ($formName == 'CRM_Contact_Form_Contact' && $ogID && $form->_contactType == 'Individual') {
        //add government fields
        $contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $form);
        $templatePath = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.hrui') . '/templates';
        $form->add('text', 'GovernmentId', ts('Government ID'));
        $form->addElement('select', "govTypeOptions", '', CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($ogID));
        CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/CRM/HRUI/Form/contactField.tpl"));
        $action = CRM_Utils_Request::retrieve('action', 'String', $form);
        $govVal = CRM_HRIdent_Page_HRIdent::retreiveContactFieldValue($contactID);
        //set default to government type option
        $default = array();
        $default['govTypeOptions'] = CRM_Core_BAO_CustomField::getOptionGroupDefault($ogID, 'select');
        if ($action == CRM_Core_Action::UPDATE && !empty($govVal)) {
            //set key for updating specific record of contact id in custom value table
            $default['govTypeOptions'] = CRM_Utils_Array::value('type', $govVal);
            $default['GovernmentId'] = CRM_Utils_Array::value('typeNumber', $govVal);
        }
        $form->setDefaults($default);
    }
}
開發者ID:JoeMurray,項目名稱:civihr,代碼行數:40,代碼來源:hrui.php

示例2: formatCustomValues


//.........這裏部分代碼省略.........
             // note that if its not text / textarea, the code falls thru and executes
             // the below case also
         // note that if its not text / textarea, the code falls thru and executes
         // the below case also
         case 'StateProvince':
         case 'Country':
             $options = array();
             $coDAO = NULL;
             //added check for Multi-Select in the below if-statement
             $customData[] = $value;
             //form custom data for multiple-valued custom data
             switch ($htmlType) {
                 case 'Multi-Select Country':
                 case 'Select Country':
                     $customData = $value;
                     if (!is_array($value)) {
                         $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     }
                     $query = "\n                    SELECT id as value, name as label\n                    FROM civicrm_country";
                     $coDAO = CRM_Core_DAO::executeQuery($query);
                     break;
                 case 'Select State/Province':
                 case 'Multi-Select State/Province':
                     $customData = $value;
                     if (!is_array($value)) {
                         $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     }
                     $query = "\n                    SELECT id as value, name as label\n                    FROM civicrm_state_province";
                     $coDAO = CRM_Core_DAO::executeQuery($query);
                     break;
                 case 'Select':
                     $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                     if ($option_group_id) {
                         $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id);
                     }
                     break;
                 case 'CheckBox':
                 case 'AdvMulti-Select':
                 case 'Multi-Select':
                     $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                 default:
                     if ($option_group_id) {
                         $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id);
                     }
             }
             if (is_object($coDAO)) {
                 while ($coDAO->fetch()) {
                     if ($dataType == 'Country') {
                         // NB: using ts() on a variable here is OK, since the value is pre-determined, not variable
                         // and already extracted to .pot files.
                         $options[$coDAO->value] = ts($coDAO->label, array('context' => 'country'));
                     } elseif ($dataType == 'StateProvince') {
                         $options[$coDAO->value] = ts($coDAO->label, array('context' => 'province'));
                     } else {
                         $options[$coDAO->value] = $coDAO->label;
                     }
                 }
             }
             CRM_Utils_Hook::customFieldOptions($field['id'], $options, FALSE);
             $retValue = NULL;
             foreach ($options as $optionValue => $optionLabel) {
                 if ($dataType == 'Money') {
                     foreach ($customData as $k => $v) {
                         $customData[] = CRM_Utils_Money::format($v, NULL, '%a');
                     }
                 }
開發者ID:hguru,項目名稱:224Civi,代碼行數:67,代碼來源:CustomGroup.php


注:本文中的CRM_Core_BAO_OptionValue::getOptionValuesAssocArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。