本文整理汇总了PHP中CRM_Core_Form::getElementValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::getElementValue方法的具体用法?PHP CRM_Core_Form::getElementValue怎么用?PHP CRM_Core_Form::getElementValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::getElementValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCampaign
/**
* Add select element for campaign
* and assign needful info to templates.
*
* @param CRM_Core_Form $form
* @param int $connectedCampaignId
*/
public static function addCampaign(&$form, $connectedCampaignId = NULL)
{
//some forms do set default and freeze.
$appendDates = TRUE;
if ($form->get('action') & CRM_Core_Action::VIEW) {
$appendDates = FALSE;
}
$campaignDetails = self::getPermissionedCampaigns($connectedCampaignId, NULL, TRUE, TRUE, $appendDates);
$fields = array('campaigns', 'hasAccessCampaign', 'isCampaignEnabled');
foreach ($fields as $fld) {
${$fld} = CRM_Utils_Array::value($fld, $campaignDetails);
}
//lets see do we have past campaigns.
$hasPastCampaigns = FALSE;
$allActiveCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, TRUE, FALSE);
if (count($allActiveCampaigns) > count($campaigns)) {
$hasPastCampaigns = TRUE;
}
$hasCampaigns = FALSE;
if (!empty($campaigns)) {
$hasCampaigns = TRUE;
}
if ($hasPastCampaigns) {
$hasCampaigns = TRUE;
$form->add('hidden', 'included_past_campaigns');
}
$showAddCampaign = FALSE;
$alreadyIncludedPastCampaigns = FALSE;
if ($connectedCampaignId || $isCampaignEnabled && $hasAccessCampaign) {
$showAddCampaign = TRUE;
//lets add past campaigns as options to quick-form element.
if ($hasPastCampaigns && $form->getElementValue('included_past_campaigns')) {
$campaigns = $allActiveCampaigns;
$alreadyIncludedPastCampaigns = TRUE;
}
$campaign =& $form->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns, FALSE, array('class' => 'crm-select2'));
//lets freeze when user does not has access or campaign is disabled.
if (!$isCampaignEnabled || !$hasAccessCampaign) {
$campaign->freeze();
}
}
$addCampaignURL = NULL;
if (empty($campaigns) && $hasAccessCampaign && $isCampaignEnabled) {
$addCampaignURL = CRM_Utils_System::url('civicrm/campaign/add', 'reset=1');
}
$includePastCampaignURL = NULL;
if ($hasPastCampaigns && $isCampaignEnabled && $hasAccessCampaign) {
$includePastCampaignURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Campaign_Page_AJAX&fnName=allActiveCampaigns', FALSE, NULL, FALSE);
}
//carry this info to templates.
$infoFields = array('hasCampaigns', 'addCampaignURL', 'showAddCampaign', 'hasPastCampaigns', 'hasAccessCampaign', 'isCampaignEnabled', 'includePastCampaignURL', 'alreadyIncludedPastCampaigns');
foreach ($infoFields as $fld) {
$campaignInfo[$fld] = ${$fld};
}
$form->assign('campaignInfo', $campaignInfo);
}