本文整理汇总了PHP中CRM_Core_Form类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form类的具体用法?PHP CRM_Core_Form怎么用?PHP CRM_Core_Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* @param CRM_Core_Form $form
*
* @return array
*/
public static function process(&$form)
{
if ($form->getVar('_surveyId') <= 0) {
return NULL;
}
$tabs = array('main' => array('title' => ts('Main Information'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'questions' => array('title' => ts('Questions'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE), 'results' => array('title' => ts('Results'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE));
$surveyID = $form->getVar('_surveyId');
$class = $form->getVar('_name');
$class = CRM_Utils_String::getClassName($class);
$class = strtolower($class);
if (array_key_exists($class, $tabs)) {
$tabs[$class]['current'] = TRUE;
$qfKey = $form->get('qfKey');
if ($qfKey) {
$tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
}
}
if ($surveyID) {
$reset = !empty($_GET['reset']) ? 'reset=1&' : '';
foreach ($tabs as $key => $value) {
if (!isset($tabs[$key]['qfKey'])) {
$tabs[$key]['qfKey'] = NULL;
}
$tabs[$key]['link'] = CRM_Utils_System::url("civicrm/survey/configure/{$key}", "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}");
$tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE;
}
}
return $tabs;
}
示例2: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Multiple Value Custom Group Search and Export');
$form->add('text', 'sort_name', ts('Contact Name'), TRUE);
// add select for contact type
//@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
$form->add('select', 'contact_type', ts('Find...'), $contactTypes, array('class' => 'crm-select2 huge'));
// add select for groups
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
$form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
// add select for tags
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge'));
if (empty($this->_groupTree)) {
CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."), CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'));
}
// add the checkbox for custom_groups
foreach ($this->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
$form->addElement('checkbox', "custom_group[{$groupID}]", NULL, $group['title']);
}
}
示例3: Paytrail_civicrm_buildForm
/**
* Implements CiviCRM 'buildForm' hook.
*
* @param string $formName Name of current form.
* @param CRM_Core_Form $form Current form.
*/
function Paytrail_civicrm_buildForm($formName, &$form)
{
//Confirm Contribution
if ($form instanceof CRM_Contribute_Form_Contribution_Confirm) {
$paymentHelper = new PaytrailPaymentHelper();
if (!$paymentHelper->isEmbeddedButtonsEnabled()) {
return;
}
//Get form params to get customer contact info and product info
$component = "contribute";
$params = $form->get("params");
$params['item_name'] = $form->_values['title'];
$paymentHelper->embeddPaymentButtons($params, $component);
} else {
if ($form instanceof CRM_Event_Form_Registration_Confirm) {
$paymentHelper = new PaytrailPaymentHelper();
if (!$paymentHelper->isEmbeddedButtonsEnabled()) {
return;
}
//Get form params to get customer contact info and product info
$component = "event";
$formParamsArray = $form->get("params");
$params = $formParamsArray[0];
$params['item_name'] = $form->_values['event']['title'];
$paymentHelper->embeddPaymentButtons($params, $component);
}
}
}
示例4: addElements
public function addElements(CRM_Core_Form &$form)
{
$form->add('select', 'XWeekDay_week_offset', ts('Offset'), $this->getWeekOffset());
$form->add('select', 'XWeekDay_day', ts('Days'), $this->getDays());
$form->add('text', 'XWeekDay_time_hour', ts('Time (hour)'));
$form->add('text', 'XWeekDay_time_minute', ts('Time (minute)'));
}
示例5: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Find Latest Activities');
/**
* Define the search form fields here
*/
// Allow user to choose which type of contact to limit search on
$form->add('select', 'contact_type', ts('Find...'), CRM_Core_SelectValues::contactType());
// Text box for Activity Subject
$form->add('text', 'activity_subject', ts('Activity Subject'));
// Select box for Activity Type
$activityType = array('' => ' - select activity - ') + CRM_Core_PseudoConstant::activityType();
$form->add('select', 'activity_type_id', ts('Activity Type'), $activityType, FALSE);
// textbox for Activity Status
$activityStatus = array('' => ' - select status - ') + CRM_Core_PseudoConstant::activityStatus();
$form->add('select', 'activity_status_id', ts('Activity Status'), $activityStatus, FALSE);
// Activity Date range
$form->addDate('start_date', ts('Activity Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
// Contact Name field
$form->add('text', 'sort_name', ts('Contact Name'));
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('contact_type', 'activity_subject', 'activity_type_id', 'activity_status_id', 'start_date', 'end_date', 'sort_name'));
}
示例6: buildQuickForm
/**
* Build the form object elements for Demographics object.
*
* @param CRM_Core_Form $form
* Reference to the form object.
*/
public static function buildQuickForm(&$form)
{
$form->addField('gender_id', array('entity' => 'contact', 'type' => 'Radio', 'allowClear' => TRUE));
$form->addField('birth_date', array('entity' => 'contact', 'formatType' => 'birth'));
$form->addField('is_deceased', array('entity' => 'contact', 'label' => ts('Contact is Deceased'), 'onclick' => "showDeceasedDate()"));
$form->addField('deceased_date', array('entity' => 'contact', 'formatType' => 'birth'));
}
示例7: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
$config = CRM_Core_Config::singleton();
$countryDefault = $config->defaultContactCountry;
$form->add('text', 'distance', ts('Distance'), NULL, TRUE);
$proxUnits = array('km' => ts('km'), 'miles' => ts('miles'));
$form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, TRUE);
$form->add('text', 'street_address', ts('Street Address'));
$form->add('text', 'city', ts('City'));
$form->add('text', 'postal_code', ts('Postal Code'));
$defaults = array();
if ($countryDefault) {
$defaults['country_id'] = $countryDefault;
}
$form->addChainSelect('state_province_id');
$country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
$form->add('select', 'country_id', ts('Country'), $country, TRUE, array('class' => 'crm-select2'));
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup();
$form->addElement('select', 'group', ts('Group'), $group, array('class' => 'crm-select2 huge'));
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tag'), $tag, array('class' => 'crm-select2 huge'));
/**
* You can define a custom title for the search form
*/
$this->setTitle('Proximity Search');
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', array('distance', 'prox_distance_unit', 'street_address', 'city', 'postal_code', 'country_id', 'state_province_id', 'group', 'tag'));
}
示例8: 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'));
}
示例9: buildQuickForm
/**
* @param CRM_Core_Form $form
*/
public static function buildQuickForm(&$form)
{
$form->removeElement('status_id');
$form->removeElement('priority_id');
$caseId = CRM_Utils_Array::first($form->_caseId);
$currentStartDate = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'start_date');
$form->assign('current_start_date', $currentStartDate);
$form->addDate('start_date', ts('New Start Date'), FALSE, array('formatType' => 'activityDateTime'));
}
示例10: preProcessCommon
/**
* Common pre-process function.
*
* @param CRM_Core_Form $form
* @param bool $useTable
*/
public static function preProcessCommon(&$form, $useTable = FALSE)
{
$form->_activityHolderIds = array();
$values = $form->controller->exportValues($form->get('searchFormName'));
$form->_task = $values['task'];
$activityTasks = CRM_Activity_Task::tasks();
$form->assign('taskName', $activityTasks[$form->_task]);
$ids = array();
if ($values['radio_ts'] == 'ts_sel') {
foreach ($values as $name => $value) {
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
}
}
} else {
$queryParams = $form->get('queryParams');
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_ACTIVITY);
$query->_distinctComponentClause = '( civicrm_activity.id )';
$query->_groupByComponentClause = " GROUP BY civicrm_activity.id ";
// CRM-12675
$activityClause = NULL;
$components = CRM_Core_Component::getNames();
$componentClause = array();
foreach ($components as $componentID => $componentName) {
if (!CRM_Core_Permission::check("access {$componentName}")) {
$componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) ";
}
}
if (!empty($componentClause)) {
$activityClause = implode(' AND ', $componentClause);
}
$result = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $activityClause);
while ($result->fetch()) {
if (!empty($result->activity_id)) {
$ids[] = $result->activity_id;
}
}
}
if (!empty($ids)) {
$form->_componentClause = ' civicrm_activity.id IN ( ' . implode(',', $ids) . ' ) ';
$form->assign('totalSelectedActivities', count($ids));
}
$form->_activityHolderIds = $form->_componentIds = $ids;
// Set the context for redirection for any task actions.
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= "&qfKey={$qfKey}";
}
$session = CRM_Core_Session::singleton();
$searchFormName = strtolower($form->get('searchFormName'));
if ($searchFormName == 'search') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/activity/search', $urlParams));
} else {
$session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/{$searchFormName}", $urlParams));
}
}
示例11: postProcessMembers
/**
* Process the form after the input has been submitted and validated.
* @todo this is horrible copy & paste code because there is so much risk of breakage
* in fixing the existing pdfLetter classes to be suitably generic
*
* @param CRM_Core_Form $form
* @param $membershipIDs
* @param $skipOnHold
* @param $skipDeceased
* @param $contactIDs
*/
public static function postProcessMembers(&$form, $membershipIDs, $skipOnHold, $skipDeceased, $contactIDs)
{
$formValues = $form->controller->exportValues($form->getName());
list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues);
$html = self::generateHTML($membershipIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $html_message, $categories);
self::createActivities($form, $html_message, $contactIDs);
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
$form->postProcessHook();
CRM_Utils_System::civiExit(1);
}
示例12: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
$groups = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(FALSE);
$form->addElement('select', 'group_id', ts('Group'), $groups, array('class' => 'crm-select2 huge'));
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', array('group_id'));
}
示例13: buildQuickForm
/**
* build the form elements for a phone object
*
* @param CRM_Core_Form $form reference to the form object
* @param int $addressBlockCount block number to build
* @param boolean $blockEdit is it block edit
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE)
{
// passing this via the session is AWFUL. we need to fix this
if (!$addressBlockCount) {
$blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1;
} else {
$blockId = $addressBlockCount;
}
$form->applyFilter('__ALL__', 'trim');
//phone type select
$form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
//main phone number with crm_phone class
$form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve')));
// phone extension
$form->addElement('text', "phone[{$blockId}][phone_ext]", ts('Extension'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone_ext'));
if (isset($form->_contactType) || $blockEdit) {
//Block type select
$form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'));
//is_Primary radio
$js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
$form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js);
}
// TODO: set this up as a group, we need a valid phone_type_id if we have a phone number
// $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' );
}
示例14: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Find Contributors by Aggregate Totals');
/**
* Define the search form fields here
*/
$form->add('text', 'min_amount', ts('Aggregate Total Between $'));
$form->addRule('min_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
$form->add('text', 'max_amount', ts('...and $'));
$form->addRule('max_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
$form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
$financial_types = CRM_Contribute_PseudoConstant::financialType();
foreach ($financial_types as $financial_type_id => $financial_type) {
$form->addElement('checkbox', "financial_type_id[{$financial_type_id}]", 'Financial Type', $financial_type);
}
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('min_amount', 'max_amount', 'start_date', 'end_date', 'financial_type_id'));
}
示例15: buildForm
/**
* Prepare a set of search fields
*
* @param CRM_Core_Form $form modifiable
* @return void
*/
function buildForm(&$form)
{
CRM_Utils_System::setTitle(ts('Find Post Code'));
$form->add('text', 'post_code', 'Post Code');
$form->add('select', 'post_city', 'Post City', $this->citiesList);
$defaults = $this->retrieveDefaultValues();
if (!empty($defaults)) {
$form->setDefaults($defaults);
}
$form->assign('elements', array('post_code', 'post_city'));
}