本文整理汇总了PHP中CRM_Core_Form::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::assign方法的具体用法?PHP CRM_Core_Form::assign怎么用?PHP CRM_Core_Form::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Build all the data structures needed to build the form.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function preProcess(&$form)
{
$messageText = array();
$messageSubject = array();
$dao = new CRM_Core_BAO_MessageTemplate();
$dao->is_active = 1;
$dao->find();
while ($dao->fetch()) {
$messageText[$dao->id] = $dao->msg_text;
$messageSubject[$dao->id] = $dao->msg_subject;
}
$form->assign('message', $messageText);
$form->assign('messageSubject', $messageSubject);
CRM_Utils_System::setTitle('Create Printable Letters (PDF)');
}
示例2: buildForm
/**
* Prepare a set of search fields
*
* @param CRM_Core_Form $form modifiable
* @return void
*/
function buildForm(&$form)
{
CRM_Utils_System::setTitle(ts('Custom Search Group Contact'));
$aElements = array();
#get all groups
$aGroups = CRM_Core_PseudoConstant::group();
$form->addElement('advmultiselect', 'group_contact', ts('Group(s)') . ' ', $aGroups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
#assign to element
$aElements[] = 'group_contact';
#date range
$form->addDate('start_date', 'From :', FALSE, array('formatType' => 'searchDate'));
$form->addDate('end_date', 'To :', FALSE, array('formatType' => 'searchDate'));
$aElements[] = 'start_date';
$aElements[] = 'end_date';
#to get all status
/*$oGroupContact = new CRM_Contact_DAO_GroupContact;
$aGroupFields = $oGroupContact->fields();
$sStatus = $aGroupFields['status']['enumValues'];
$aStatus = explode(', ', $sStatus);*/
$aStatus = CRM_Core_SelectValues::groupContactStatus();
foreach ($aStatus as $status) {
//$form->addElement('checkbox', "status[{$status}]",$status, '', array('class' => 'group_status'));
$form->addElement('checkbox', $status, ts("{$status}"), '', array('class' => 'group_status'));
//$form->addElement('checkbox', "status[{$status}]" , $status, '', array('class' => 'group_status'));
$aElements[] = $status;
}
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$this->_elements = $aElements;
$form->assign('elements', $aElements);
}
示例3: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Find Totals for Events');
/**
* Define the search form fields here
*/
$form->addElement('checkbox', 'paid_online', ts('Only show Credit Card Payments'));
$form->addElement('checkbox', 'show_payees', ts('Show payees'));
$event_type = CRM_Core_OptionGroup::values('event_type', FALSE);
foreach ($event_type as $eventId => $eventName) {
$form->addElement('checkbox', "event_type_id[{$eventId}]", 'Event Type', $eventName);
}
$events = CRM_Event_BAO_Event::getEvents(1);
$form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events);
$form->addDate('start_date', ts('Payments Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id'));
}
示例4: 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'));
}
示例5: 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'));
}
示例6: 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'));
}
示例7: preProcess
/**
* @param CRM_Core_Form $form
*
* @throws Exception
*/
public static function preProcess(&$form)
{
if (empty($form->_caseId)) {
CRM_Core_Error::fatal(ts('Case Id not found.'));
}
if (count($form->_caseId) != 1) {
CRM_Core_Resources::fatal(ts('Expected one case-type'));
}
$caseId = CRM_Utils_Array::first($form->_caseId);
$form->assign('clientID', $form->_currentlyViewedContactId);
$form->assign('sortName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $form->_currentlyViewedContactId, 'sort_name'));
$form->assign('caseTypeLabel', CRM_Case_BAO_Case::getCaseType($caseId));
// get the related cases for given case.
$relatedCases = $form->get('relatedCases');
if (!isset($relatedCases)) {
$relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $form->_currentlyViewedContactId);
$form->set('relatedCases', empty($relatedCases) ? FALSE : $relatedCases);
}
}
示例8: 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'));
}
示例9: add
/**
* Add element to form.
*
* @param CRM_Core_Form $form
*/
public static function add(&$form)
{
$error = NULL;
$config = CRM_Core_Config::singleton();
$useSSL = FALSE;
if (!function_exists('recaptcha_get_html')) {
require_once 'packages/recaptcha/recaptchalib.php';
}
// See if we are using SSL
if (CRM_Utils_System::isSSL()) {
$useSSL = TRUE;
}
$html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useSSL);
$form->assign('recaptchaHTML', $html);
$form->assign('recaptchaOptions', $config->recaptchaOptions);
$form->add('text', 'g-recaptcha-response', 'reCaptcha', NULL, TRUE);
$form->registerRule('recaptcha', 'callback', 'validate', 'CRM_Utils_ReCAPTCHA');
if ($form->isSubmitted() && empty($form->_submitValues['g-recaptcha-response'])) {
$form->setElementError('g-recaptcha-response', ts('Input text must match the phrase in the image. Please review the image and re-enter matching text.'));
}
}
示例10: buildQuickForm
/**
* build the form elements for Communication Preferences object
*
* @param CRM_Core_Form $form reference to the form object
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form)
{
// since the pcm - preferred comminication method is logically
// grouped hence we'll use groups of HTML_QuickForm
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$privacy = $commPreff = $commPreference = array();
$privacyOptions = CRM_Core_SelectValues::privacy();
// we add is_opt_out as a separate checkbox below for display and help purposes so remove it here
unset($privacyOptions['is_opt_out']);
foreach ($privacyOptions as $name => $label) {
$privacy[] = $form->createElement('advcheckbox', $name, NULL, $label);
}
$form->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
// preferred communication method
$comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method', array('loclize' => TRUE));
foreach ($comm as $value => $title) {
$commPreff[] = $form->createElement('advcheckbox', $value, NULL, $title);
}
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Method(s)'));
$form->addSelect('preferred_language');
if (!empty($privacyOptions)) {
$commPreference['privacy'] = $privacyOptions;
}
if (!empty($comm)) {
$commPreference['preferred_communication_method'] = $comm;
}
//using for display purpose.
$form->assign('commPreference', $commPreference);
$form->add('select', 'preferred_mail_format', ts('Email Format'), CRM_Core_SelectValues::pmf());
$form->add('checkbox', 'is_opt_out', ts('NO BULK EMAILS (User Opt Out)'));
$communicationStyleOptions = array();
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id', array('localize' => TRUE));
foreach ($communicationStyle as $key => $var) {
$communicationStyleOptions[$key] = $form->createElement('radio', NULL, ts('Communication Style'), $var, $key, array('id' => "civicrm_communication_style_{$var}_{$key}"));
}
if (!empty($communicationStyleOptions)) {
$form->addGroup($communicationStyleOptions, 'communication_style_id', ts('Communication Style'));
}
//check contact type and build filter clause accordingly for greeting types, CRM-4575
$greetings = self::getGreetingFields($form->_contactType);
foreach ($greetings as $greeting => $fields) {
$filter = array('contact_type' => $form->_contactType, 'greeting_type' => $greeting);
//add addressee in Contact form
$greetingTokens = CRM_Core_PseudoConstant::greeting($filter);
if (!empty($greetingTokens)) {
$form->addElement('select', $fields['field'], $fields['label'], array('' => ts('- select -')) + $greetingTokens);
//custom addressee
$form->addElement('text', $fields['customField'], $fields['customLabel'], CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', $fields['customField']), $fields['js']);
}
}
}
示例11: buildForm
/**
* Prepare a set of search fields
*
* @param CRM_Core_Form $form modifiable
* @return void
*/
function buildForm(&$form)
{
CRM_Utils_System::setTitle(ts('My Search Title'));
$form->add('text', 'household_name', ts('Household Name'), TRUE);
$stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
$form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
// Optionally define default search values
$form->setDefaults(array('household_name' => '', 'state_province_id' => NULL));
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', array('household_name', 'state_province_id'));
}
示例12: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
$form->add('text', 'postal_code_low', ts('Postal Code Start'), TRUE);
$form->add('text', 'postal_code_high', ts('Postal Code End'), TRUE);
/**
* You can define a custom title for the search form
*/
$this->setTitle('Zip Code Range 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('postal_code_low', 'postal_code_high'));
}
示例13: buildQuickForm
/**
* This is function is called by the form object to get the DataSource's
* form snippet. It should add all fields necesarry to get the data
* uploaded to the temporary table in the DB.
*
* @param CRM_Core_Form $form
*
* @return void
* (operates directly on form argument)
*/
public function buildQuickForm(&$form)
{
$form->add('hidden', 'hidden_dataSource', 'CRM_Import_DataSource_CSV');
$config = CRM_Core_Config::singleton();
$uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE);
$uploadSize = round($uploadFileSize / (1024 * 1024), 2);
$form->assign('uploadSize', $uploadSize);
$form->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
$form->setMaxFileSize($uploadFileSize);
$form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
$form->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$form->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
$form->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
}
示例14: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
$form->add('select', 'contact_type', ts('Find...'), $contactTypes, FALSE, array('class' => 'crm-select2 huge'));
// add select for groups
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup();
$form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
// add select for categories
$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'));
// text for sort_name
$form->add('text', 'sort_name', ts('Name'));
$form->assign('elements', array('sort_name', 'contact_type', 'group', 'tag'));
}
示例15: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
$form->add('text', 'segmentSize', ts('Segment Size'), TRUE);
$groups = CRM_Core_PseudoConstant::nestedGroup();
$select2style = array('multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'));
$form->add('select', 'includeGroups', ts('Include Group(s)'), $groups, FALSE, $select2style);
$form->add('select', 'excludeGroups', ts('Exclude Group(s)'), $groups, FALSE, $select2style);
$this->setTitle('Create a random segment of contacts');
/**
* if you are using the standard template, this array tells the template what elements
* are part of the search criteria
*/
$form->assign('elements', array('segmentSize', 'includeGroups', 'excludeGroups'));
}