本文整理汇总了PHP中CRM_Core_Form::getAction方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::getAction方法的具体用法?PHP CRM_Core_Form::getAction怎么用?PHP CRM_Core_Form::getAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::getAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: menufontawesome_civicrm_buildForm
/**
* Implements hook_civicrm_buildForm().
*
* Set a default value for an event price set field.
*
* @param string $formName
* @param CRM_Core_Form $form
*/
function menufontawesome_civicrm_buildForm($formName, &$form)
{
if ($formName == 'CRM_Admin_Form_Navigation') {
CRM_Core_Resources::singleton()->addStyleFile('com.opetmar.menufontawesome', 'resources/plugins/bootstrap/css/bootstrap.css', 0, 'html-header');
CRM_Core_Resources::singleton()->addStyleFile('com.opetmar.menufontawesome', 'resources/plugins/fontawesome-iconpicker/css/fontawesome-iconpicker.min.css', 0, 'html-header');
CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/plugins/jquery-1.11.3.min.js', 0);
CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/plugins/bootstrap/js/bootstrap.min.js', 1);
CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/plugins/fontawesome-iconpicker/js/fontawesome-iconpicker.min.js', 2);
CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/main.js', 3);
// Add the field element in the form
if ($form->getAction() == CRM_Core_Action::UPDATE) {
$id = $form->getVar('_id');
$fa_icon = CRM_Menufontawesome_BAO_Navigation::getIcon($id);
$form->add('text', 'fa_icon', ts('Icon'), array('value' => $fa_icon));
} else {
$form->add('text', 'fa_icon', ts('Icon'), array('value' => ''));
}
$templatePath = realpath(dirname(__FILE__) . "/templates/CRM/Menufontawesome/Page");
// dynamically insert a template block in the page
CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/fa_icon.tpl"));
}
}
示例2: buildQuickForm
/**
* Function used to build form element for soft credit block.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildQuickForm(&$form)
{
if (!empty($form->_honor_block_is_active)) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
if ($ufJoinDAO->find(TRUE)) {
$jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
if ($jsonData) {
foreach (array('honor_block_title', 'honor_block_text') as $name) {
$form->assign($name, $jsonData[$name]);
}
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
// radio button for Honor Type
foreach ($jsonData['soft_credit_types'] as $value) {
$honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
}
$form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
}
}
return $form;
}
// by default generate 10 blocks
$item_count = 11;
$showSoftCreditRow = 2;
if ($form->getAction() & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
} elseif (!empty($form->_pledgeID)) {
//Check and select most recent completed contrubtion and use it to retrieve
//soft-credit information to use as default for current pledge payment, CRM-13981
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
foreach ($pledgePayments as $id => $record) {
if ($record['contribution_id']) {
$softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
if ($record['status'] == 'Completed' && count($softCredits) > 0) {
$form->_softCreditInfo = $softCredits;
}
}
}
}
if (property_exists($form, "_softCreditInfo")) {
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
}
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
$form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
$form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
$form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
}
}
// CRM-7368 allow user to set or edit PCP link for contributions
$siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
$form->assign('siteHasPCPs', 1);
// Fixme: Not a true entityRef field. Relies on PCP.js.tpl
$form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -')));
// stores the label
$form->add('hidden', 'pcp_made_through');
$form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
$form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
$form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
}
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
$form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
}
示例3: hremerg_civicrm_buildForm
/**
* @param string $formName
* @param CRM_Core_Form $form
*/
function hremerg_civicrm_buildForm($formName, &$form)
{
if ($formName == 'CRM_Contact_Form_Relationship' && empty($form->_caseId)) {
if ($form->elementExists('relationship_type_id') && $form->_contactType == 'Individual') {
$relationshipType = civicrm_api3('relationship_type', 'get', array('name_a_b' => 'Emergency Contact'));
$select = $form->getElement('relationship_type_id');
$select->freeze();
$select->setLabel('');
$form->getElement('related_contact_id')->setLabel('');
if ($form->getAction() & CRM_Core_Action::ADD && !empty($relationshipType['id'])) {
$form->setDefaults(array('relationship_type_id' => $relationshipType['id'] . '_a_b'));
}
}
}
}
示例4: buildQuickForm
/**
* Function used to build form element for soft credit block.
*
* @param CRM_Core_Form $form
*
* @return \CRM_Core_Form
*/
public static function buildQuickForm(&$form)
{
if (!empty($form->_honor_block_is_active)) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
if ($ufJoinDAO->find(TRUE)) {
$jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit');
if ($jsonData) {
foreach (array('honor_block_title', 'honor_block_text') as $name) {
$form->assign($name, $jsonData[$name]);
}
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
// radio button for Honor Type
foreach ($jsonData['soft_credit_types'] as $value) {
$honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
}
$form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
}
}
return $form;
}
// by default generate 10 blocks
$item_count = 11;
$showSoftCreditRow = 2;
if ($form->getAction() & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
} elseif (!empty($form->_pledgeID)) {
//Check and select most recent completed contrubtion and use it to retrieve
//soft-credit information to use as default for current pledge payment, CRM-13981
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
foreach ($pledgePayments as $id => $record) {
if ($record['contribution_id']) {
$softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
if ($record['status'] == 'Completed' && count($softCredits) > 0) {
$form->_softCreditInfo = $softCredits;
}
}
}
}
if (property_exists($form, "_softCreditInfo")) {
if (!empty($form->_softCreditInfo['soft_credit'])) {
$showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
$showSoftCreditRow++;
}
}
for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
$form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
$form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
$form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
$form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
}
}
self::addPCPFields($form);
$form->assign('showSoftCreditRow', $showSoftCreditRow);
$form->assign('rowCount', $item_count);
$form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
}