本文整理汇总了PHP中CRM_Core_BAO_CustomField::getOptionGroupDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::getOptionGroupDefault方法的具体用法?PHP CRM_Core_BAO_CustomField::getOptionGroupDefault怎么用?PHP CRM_Core_BAO_CustomField::getOptionGroupDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::getOptionGroupDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}