本文整理汇总了PHP中CRM_Core_Form::getProfileDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::getProfileDefaults方法的具体用法?PHP CRM_Core_Form::getProfileDefaults怎么用?PHP CRM_Core_Form::getProfileDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::getProfileDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* Set default values for the form.
*
* @param CRM_Core_Form $form
* @param int $contactID
*/
public static function setDefaultValues(&$form, $contactID)
{
$billingDefaults = $form->getProfileDefaults('Billing', $contactID);
$form->_defaults = array_merge($form->_defaults, $billingDefaults);
// set default country & state from config if no country set
// note the effect of this is to set the billing country to default to the site default
// country if the person has an address but no country (for anonymous country is set above)
// this could have implications if the billing profile is filled but hidden.
// this behaviour has been in place for a while but the use of js to hide things has increased
if (empty($form->_defaults["billing_country_id-{$form->_bltID}"])) {
$form->_defaults["billing_country_id-{$form->_bltID}"] = CRM_Core_Config::singleton()->defaultContactCountry;
}
if (empty($form->_defaults["billing_state_province_id-{$form->_bltID}"])) {
$form->_defaults["billing_state_province_id-{$form->_bltID}"] = CRM_Core_Config::singleton()->defaultContactStateProvince;
}
}
示例2: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function setDefaultValues(&$form)
{
$defaults = array();
if ($form->_eventId) {
//get receipt text and financial type
$returnProperities = array('confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date');
$details = array();
CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
if (!empty($details[$form->_eventId]['financial_type_id'])) {
$defaults[$form->_pId]['financial_type_id'] = $details[$form->_eventId]['financial_type_id'];
}
}
if ($form->_pId) {
$ids = array();
$params = array('id' => $form->_pId);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
if ($form->_action == CRM_Core_Action::UPDATE) {
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$value = current($value);
$discounts[$key] = $value['name'];
}
}
if ($form->_discountId && !empty($discounts[$defaults[$form->_pId]['discount_id']])) {
$form->assign('discount', $discounts[$defaults[$form->_pId]['discount_id']]);
}
$form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
$form->assign('fee_level', CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]));
}
$defaults[$form->_pId]['send_receipt'] = 0;
} else {
$defaults[$form->_pId]['send_receipt'] = strtotime(CRM_Utils_Array::value('start_date', $details[$form->_eventId])) >= time() ? 1 : 0;
if ($form->_eventId && !empty($details[$form->_eventId]['confirm_email_text'])) {
//set receipt text
$defaults[$form->_pId]['receipt_text'] = $details[$form->_eventId]['confirm_email_text'];
}
list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults();
}
//CRM-11601 we should keep the record contribution
//true by default while adding participant
if ($form->_action == CRM_Core_Action::ADD && !$form->_mode && $form->_isPaidEvent) {
$defaults[$form->_pId]['record_contribution'] = 1;
}
//CRM-13420
if (empty($defaults['payment_instrument_id'])) {
$defaults[$form->_pId]['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
if ($form->_mode) {
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
if (empty($defaults[$form->_pId]["billing_country_id-{$form->_bltID}"])) {
$defaults[$form->_pId]["billing_country_id-{$form->_bltID}"] = $config->defaultContactCountry;
}
if (empty($defaults["billing_state_province_id-{$form->_bltID}"])) {
$defaults[$form->_pId]["billing_state_province_id-{$form->_bltID}"] = $config->defaultContactStateProvince;
}
$billingDefaults = $form->getProfileDefaults('Billing', $form->_contactId);
$defaults[$form->_pId] = array_merge($defaults[$form->_pId], $billingDefaults);
// // hack to simplify credit card entry for testing
// $defaults[$form->_pId]['credit_card_type'] = 'Visa';
// $defaults[$form->_pId]['credit_card_number'] = '4807731747657838';
// $defaults[$form->_pId]['cvv2'] = '000';
// $defaults[$form->_pId]['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
}
// if user has selected discount use that to set default
if (isset($form->_discountId)) {
$defaults[$form->_pId]['discount_id'] = $form->_discountId;
//hack to set defaults for already selected discount value
if ($form->_action == CRM_Core_Action::UPDATE && !$form->_originalDiscountId) {
$form->_originalDiscountId = $defaults[$form->_pId]['discount_id'];
if ($form->_originalDiscountId) {
$defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId;
}
}
$discountId = $form->_discountId;
} else {
$discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
}
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
} else {
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $form->_eventId);
}
if ($form->_action == CRM_Core_Action::ADD && $form->_eventId && $discountId) {
// this case is for add mode, where we show discount automatically
$defaults[$form->_pId]['discount_id'] = $discountId;
}
if ($priceSetId) {
// get price set default values, CRM-4090
if (in_array(get_class($form), array('CRM_Event_Form_Participant', 'CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_AdditionalParticipant'))) {
//.........这里部分代码省略.........