当前位置: 首页>>代码示例>>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;未经允许,请勿转载。