本文整理汇总了PHP中CRM_Core_Form::addSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::addSelect方法的具体用法?PHP CRM_Core_Form::addSelect怎么用?PHP CRM_Core_Form::addSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::addSelect方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object elements for a phone object.
*
* @param CRM_Core_Form $form
* Reference to the form object.
* @param int $addressBlockCount
* Block number to build.
* @param bool $blockEdit
* Is it block edit.
*/
public 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->addSelect("phone[{$blockId}][phone_type_id]", array('entity' => 'phone', 'class' => 'eight', 'placeholder' => NULL));
//main phone number with crm_phone class
$form->add('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->addSelect("phone[{$blockId}][location_type_id]", array('entity' => 'phone', 'class' => 'eight', 'placeholder' => NULL));
//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' );
}
示例2: buildQuickForm
/**
* This function provides the HTML form elements that are specific
* to the Individual Contact Type
*
* @param CRM_Core_Form $form form object
* @param int $inlineEditMode ( 1 for contact summary
* top bar form and 2 for display name edit )
*
* @access public
* @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL)
{
$form->applyFilter('__ALL__', 'trim');
if (!$inlineEditMode || $inlineEditMode == 1) {
$nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
//prefix
$prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
if (isset($nameFields['Prefix']) && !empty($prefix)) {
$form->addSelect('prefix_id', array('class' => 'four', 'placeholder' => ' '));
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
if (isset($nameFields['Formal Title'])) {
$form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
}
// first_name
if (isset($nameFields['First Name'])) {
$form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
}
//middle_name
if (isset($nameFields['Middle Name'])) {
$form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
}
// last_name
if (isset($nameFields['Last Name'])) {
$form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
}
// suffix
$suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
if (isset($nameFields['Suffix']) && $suffix) {
$form->addSelect('suffix_id', array('class' => 'four', 'placeholder' => ' '));
}
}
if (!$inlineEditMode || $inlineEditMode == 2) {
// nick_name
$form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
// job title
// override the size for UI to look better
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
//Current Employer Element
$employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, FALSE, NULL, FALSE);
$form->assign('employerDataURL', $employerDataURL);
$form->addElement('text', 'current_employer', ts('Current Employer'), '');
$form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id'));
$form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
}
if (!$inlineEditMode) {
$checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
if ($checkSimilar == null) {
$checkSimilar = 0;
}
$form->assign('checkSimilar', $checkSimilar);
//External Identifier Element
$form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
$form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
$config = CRM_Core_Config::singleton();
CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
}
}
示例3: buildQuickForm
/**
* This function provides the HTML form elements that are specific
* to the Individual Contact Type
*
* @param CRM_Core_Form $form
* Form object.
* @param int $inlineEditMode
* ( 1 for contact summary.
* top bar form and 2 for display name edit )
*
* @return void
*/
public static function buildQuickForm(&$form, $inlineEditMode = NULL)
{
$form->applyFilter('__ALL__', 'trim');
if (!$inlineEditMode || $inlineEditMode == 1) {
$nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
//prefix
$prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
if (isset($nameFields['Prefix']) && !empty($prefix)) {
$form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix')));
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
if (isset($nameFields['Formal Title'])) {
$form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
}
// first_name
if (isset($nameFields['First Name'])) {
$form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
}
//middle_name
if (isset($nameFields['Middle Name'])) {
$form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
}
// last_name
if (isset($nameFields['Last Name'])) {
$form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
}
// suffix
$suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
if (isset($nameFields['Suffix']) && $suffix) {
$form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix')));
}
}
if (!$inlineEditMode || $inlineEditMode == 2) {
// nick_name
$form->addElement('text', 'nick_name', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
// job title
// override the size for UI to look better
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
//Current Employer Element
$props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
$form->addEntityRef('employer_id', ts('Current Employer'), $props);
$attributes['source']['class'] = 'big';
$form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
}
if (!$inlineEditMode) {
$checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
if ($checkSimilar == NULL) {
$checkSimilar = 0;
}
$form->assign('checkSimilar', $checkSimilar);
//External Identifier Element
$form->add('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), FALSE);
$form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
$config = CRM_Core_Config::singleton();
CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
}
}
示例4: buildQuickForm
/**
* build the form elements for an IM object
*
* @param CRM_Core_Form $form reference to the form object
* @param int $blockCount block number to build
* @param boolean $blockEdit is it block edit
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
{
if (!$blockCount) {
$blockId = $form->get('IM_Block_Count') ? $form->get('IM_Block_Count') : 1;
} else {
$blockId = $blockCount;
}
$form->applyFilter('__ALL__', 'trim');
//IM provider select
$form->addSelect("im[{$blockId}][provider_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL));
//Block type select
$form->addSelect("im[{$blockId}][location_type_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL));
//IM box
$form->addElement('text', "im[{$blockId}][name]", ts('Instant Messenger'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name'));
//is_Primary radio
$js = array('id' => 'IM_' . $blockId . '_IsPrimary');
if (!$blockEdit) {
$js['onClick'] = 'singleSelect( this.id );';
}
$form->addElement('radio', "im[{$blockId}][is_primary]", '', '', '1', $js);
}
示例5: buildQuickForm
/**
* Build the form object elements for Communication Preferences object.
*
* @param CRM_Core_Form $form
* Reference to the form object.
*
* @return void
*/
public 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']);
}
}
}
示例6: buildQuickForm
/**
* build the form elements for an Website object
*
* @param CRM_Core_Form $form reference to the form object
* @param int $blockCount block number to build
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form, $blockCount = NULL)
{
if (!$blockCount) {
$blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1;
} else {
$blockId = $blockCount;
}
$form->applyFilter('__ALL__', 'trim');
//Website type select
$form->addSelect("website[{$blockId}][website_type_id]", array('entity' => 'website', 'class' => 'eight'));
//Website box
$form->addElement('text', "website[{$blockId}][url]", ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false")));
$form->addRule("website[{$blockId}][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url');
}
示例7: buildQuickForm
/**
* build the form elements for an email object
*
* @param CRM_Core_Form $form reference to the form object
* @param int $blockCount block number to build
* @param boolean $blockEdit is it block edit
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
{
// passing this via the session is AWFUL. we need to fix this
if (!$blockCount) {
$blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1;
} else {
$blockId = $blockCount;
}
$form->applyFilter('__ALL__', 'trim');
//Email box
$form->addElement('text', "email[{$blockId}][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'));
$form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email');
if (isset($form->_contactType) || $blockEdit) {
//Block type
$form->addSelect("email[{$blockId}][location_type_id]", array('entity' => 'email', 'class' => 'eight', 'placeholder' => NULL));
$multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
//On-hold select
if ($multipleBulk) {
$holdOptions = array(0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out'));
$form->addElement('select', "email[{$blockId}][on_hold]", '', $holdOptions);
} else {
$form->addElement('advcheckbox', "email[{$blockId}][on_hold]", NULL);
}
//Bulkmail checkbox
$form->assign('multipleBulk', $multipleBulk);
if ($multipleBulk) {
$js = array('id' => "Email_" . $blockId . "_IsBulkmail");
$form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", NULL, '', $js);
} else {
$js = array('id' => "Email_" . $blockId . "_IsBulkmail");
if (!$blockEdit) {
$js['onClick'] = 'singleSelect( this.id );';
}
$form->addElement('radio', "email[{$blockId}][is_bulkmail]", '', '', '1', $js);
}
//is_Primary radio
$js = array('id' => "Email_" . $blockId . "_IsPrimary");
if (!$blockEdit) {
$js['onClick'] = 'singleSelect( this.id );';
}
$form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js);
if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
$form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40));
$form->addWysiwyg("email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40));
}
}
}
示例8: 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'));
$form->addSelect('financial_type_id', array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search'));
/**
* 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'));
}
示例9: buildProfile
//.........这里部分代码省略.........
$form->addDate($name, $title, $required, array('formatType' => 'birth'));
} elseif (in_array($fieldName, array('membership_start_date', 'membership_end_date', 'join_date'))) {
$form->addDate($name, $title, $required, array('formatType' => 'activityDate'));
} elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') {
list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$select = array('' => ts('- select -'));
if (count($orgInfo) == 1 && $field['is_required']) {
// we only have one org - so we should default to it. Not sure about defaulting to first type
// as it could be missed - so adding a select
// however, possibly that is more similar to the membership form
if (count($types[1]) > 1) {
$types[1] = $select + $types[1];
}
} else {
$orgInfo = $select + $orgInfo;
}
$sel->setOptions(array($orgInfo, $types));
} elseif (CRM_Utils_Array::value('name', $field) == 'membership_status') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), $required);
} elseif (in_array($fieldName, array('gender_id', 'communication_style_id'))) {
$options = array();
$pseudoValues = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $fieldName);
foreach ($pseudoValues as $key => $var) {
$options[$key] = $form->createElement('radio', NULL, ts($title), $var, $key);
}
$group = $form->addGroup($options, $name, $title);
if ($required) {
$form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required');
} else {
$group->setAttribute('allowClear', TRUE);
}
} elseif ($fieldName === 'prefix_id' || $fieldName === 'suffix_id') {
$form->addSelect($name, array('label' => $title, 'entity' => 'contact', 'field' => $fieldName, 'class' => 'six', 'placeholder' => ''), $required);
} elseif ($fieldName === 'contact_sub_type') {
$gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field);
if ($usedFor == 'onbehalf') {
$profileType = 'Organization';
} elseif ($usedFor == 'honor') {
$profileType = CRM_Core_BAO_UFField::getProfileType($form->_params['honoree_profile_id']);
} else {
$profileType = $gId ? CRM_Core_BAO_UFField::getProfileType($gId) : NULL;
if ($profileType == 'Contact') {
$profileType = 'Individual';
}
}
$setSubtype = FALSE;
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$setSubtype = $profileType;
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
$subtypes = $profileType ? CRM_Contact_BAO_ContactType::subTypePairs($profileType) : array();
if ($setSubtype) {
$subtypeList = array();
$subtypeList[$setSubtype] = $subtypes[$setSubtype];
} else {
$subtypeList = $subtypes;
}
$form->add('select', $name, $title, $subtypeList, $required, array('class' => 'crm-select2', 'multiple' => TRUE));
} elseif (in_array($fieldName, CRM_Contact_BAO_Contact::$_greetingTypes)) {
//add email greeting, postal greeting, addressee, CRM-4575
$gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field);
$profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE);
if (empty($profileType) || in_array($profileType, array('Contact', 'Contribution', 'Participant', 'Membership'))) {
$profileType = 'Individual';
}
示例10: buildSearchForm
/**
* @param CRM_Core_Form $form
*/
public static function buildSearchForm(&$form)
{
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
$form->add('select', 'membership_status_id', ts('Membership Status(s)'), $membershipStatus, FALSE, array('id' => 'membership_status_id', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$form->addSelect('membership_type_id', array('entity' => 'membership', 'multiple' => 'multiple', 'label' => ts('Membership Type(s)'), 'option_url' => NULL, 'placeholder' => ts('- any -')));
$form->addElement('text', 'member_source', ts('Source'));
CRM_Core_Form_Date::buildDateRange($form, 'member_join_date', 1, '_low', '_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'member_start_date', 1, '_low', '_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'member_end_date', 1, '_low', '_high', ts('From'), FALSE);
$form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE);
$form->addYesNo('member_pay_later', ts('Pay Later?'), TRUE);
$form->addYesNo('member_auto_renew', ts('Auto-Renew?'), TRUE);
$form->addYesNo('member_test', ts('Membership is a Test?'), TRUE);
// add all the custom searchable fields
$extends = array('Membership');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('membershipGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'member_campaign_id');
$form->assign('validCiviMember', TRUE);
$form->setDefaults(array('member_test' => 0));
}
示例11: buildSearchForm
/**
* Add all the elements shared between case activity search and advanced search.
*
*
* @param CRM_Core_Form $form
* @return void
*/
public static function buildSearchForm(&$form)
{
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$form->addSelect('activity_type_id', array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
$followUpActivity = array(1 => ts('Yes'), 2 => ts('No'));
$form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
$form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
$activityRoles = array(3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by'));
$form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
$form->setDefaults(array('activity_role' => 3));
$activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
$form->addSelect('status_id', array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
$form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
$form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$form->addYesNo('activity_test', ts('Activity is a Test?'));
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
if ($activity_tags) {
foreach ($activity_tags as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
}
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
$surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
if ($surveys) {
$form->add('select', 'activity_survey_id', ts('Survey / Petition'), array('' => ts('- none -')) + $surveys, FALSE, array('class' => 'crm-select2'));
}
$extends = array('Activity');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('activityGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
$buildSurveyResult = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
// Add survey result field.
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
$resultOptions = array();
foreach ($optionGroups as $gid => $name) {
if ($name) {
$value = array();
$value = CRM_Core_OptionGroup::values($name);
if (!empty($value)) {
while (list($k, $v) = each($value)) {
$resultOptions[$v] = $v;
}
}
}
}
// If no survey result options have been created, don't build
// the field to avoid clutter.
if (count($resultOptions) > 0) {
$buildSurveyResult = TRUE;
asort($resultOptions);
$form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2'));
}
}
$form->assign('buildEngagementLevel', $buildEngagementLevel);
$form->assign('buildSurveyResult', $buildSurveyResult);
$form->setDefaults(array('activity_test' => 0));
}
示例12: buildQuickForm
/**
* Build form for address input fields.
*
* @param CRM_Core_Form $form
* @param int $addressBlockCount
* The index of the address array (if multiple addresses on a page).
* @param bool $sharing
* False, if we want to skip the address sharing features.
* @param bool $inlineEdit
* True when edit used in inline edit.
*
* @return void
*
*/
public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharing = TRUE, $inlineEdit = FALSE)
{
// passing this via the session is AWFUL. we need to fix this
if (!$addressBlockCount) {
$blockId = $form->get('Address_Block_Count') ? $form->get('Address_Block_Count') : 1;
} else {
$blockId = $addressBlockCount;
}
$config = CRM_Core_Config::singleton();
$countryDefault = $config->defaultContactCountry;
$form->applyFilter('__ALL__', 'trim');
$js = array();
if (!$inlineEdit) {
$js = array('onChange' => 'checkLocation( this.id );', 'placeholder' => NULL);
}
//make location type required for inline edit
$form->addSelect("address[{$blockId}][location_type_id]", array('entity' => 'address', 'class' => 'eight') + $js, $inlineEdit);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
}
$form->addElement('checkbox', "address[{$blockId}][is_primary]", ts('Primary location for this contact'), ts('Primary location for this contact'), $js);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );');
}
$form->addElement('checkbox', "address[{$blockId}][is_billing]", ts('Billing location for this contact'), ts('Billing location for this contact'), $js);
// hidden element to store master address id
$form->addElement('hidden', "address[{$blockId}][master_id]");
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
$elements = array('address_name' => array(ts('Address Name'), $attributes['address_name'], NULL), 'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL), 'supplemental_address_1' => array(ts('Supplemental Address 1'), $attributes['supplemental_address_1'], NULL), 'supplemental_address_2' => array(ts('Supplemental Address 2'), $attributes['supplemental_address_2'], NULL), 'city' => array(ts('City'), $attributes['city'], NULL), 'postal_code' => array(ts('Zip / Postal Code'), array_merge($attributes['postal_code'], array('class' => 'crm_postal_code')), NULL), 'postal_code_suffix' => array(ts('Postal Code Suffix'), array('size' => 4, 'maxlength' => 12, 'class' => 'crm_postal_code_suffix'), NULL), 'country_id' => array(ts('Country'), $attributes['country_id'], 'country'), 'state_province_id' => array(ts('State/Province'), $attributes['state_province_id'], NULL), 'county_id' => array(ts('County'), $attributes['county_id'], NULL), 'geo_code_1' => array(ts('Latitude'), array('size' => 9, 'maxlength' => 12), NULL), 'geo_code_2' => array(ts('Longitude'), array('size' => 9, 'maxlength' => 12), NULL), 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL), 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL), 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL));
foreach ($elements as $name => $v) {
list($title, $attributes, $select) = $v;
$nameWithoutID = strpos($name, '_id') !== FALSE ? substr($name, 0, -3) : $name;
if (empty($addressOptions[$nameWithoutID])) {
$continue = TRUE;
if (in_array($nameWithoutID, array('street_number', 'street_name', 'street_unit')) && !empty($addressOptions['street_address_parsing'])) {
$continue = FALSE;
}
if ($continue) {
continue;
}
}
//build normal select if country is not present in address block
if ($name == 'state_province_id' && !$addressOptions['country']) {
$select = 'stateProvince';
}
if (!$select) {
if ($name == 'state_province_id' || $name == 'county_id') {
$form->addChainSelect("address[{$blockId}][{$name}]");
} else {
if ($name == 'address_name') {
$name = 'name';
}
$form->addElement('text', "address[{$blockId}][{$name}]", $title, $attributes);
}
} else {
$form->addElement('select', "address[{$blockId}][{$name}]", $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select());
}
}
$entityId = NULL;
if (!empty($form->_values['address']) && !empty($form->_values['address'][$blockId])) {
$entityId = $form->_values['address'][$blockId]['id'];
}
// CRM-11665 geocode override option
$geoCode = FALSE;
if (!empty($config->geocodeMethod)) {
$geoCode = TRUE;
$form->addElement('checkbox', "address[{$blockId}][manual_geo_code]", ts('Override automatic geocoding'));
}
$form->assign('geoCode', $geoCode);
// Process any address custom data -
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $form, $entityId);
if (isset($groupTree) && is_array($groupTree)) {
// use simplified formatted groupTree
$groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form);
// make sure custom fields are added /w element-name in the format - 'address[$blockId][custom-X]'
foreach ($groupTree as $id => $group) {
foreach ($group['fields'] as $fldId => $field) {
$groupTree[$id]['fields'][$fldId]['element_custom_name'] = $field['element_name'];
$groupTree[$id]['fields'][$fldId]['element_name'] = "address[{$blockId}][{$field['element_name']}]";
}
}
$defaults = array();
CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
// since we change element name for address custom data, we need to format the setdefault values
$addressDefaults = array();
//.........这里部分代码省略.........
示例13: location
/**
* @param CRM_Core_Form $form
*/
public static function location(&$form)
{
$config = CRM_Core_Config::singleton();
// Build location criteria based on _submitValues if
// available; otherwise, use $form->_formValues.
$formValues = $form->_submitValues;
if (empty($formValues) && !empty($form->_formValues)) {
$formValues = $form->_formValues;
}
$form->addElement('hidden', 'hidden_location', 1);
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
$elements = array('street_address' => array(ts('Street Address'), $attributes['street_address'], NULL, NULL), 'city' => array(ts('City'), $attributes['city'], NULL, NULL), 'postal_code' => array(ts('Zip / Postal Code'), $attributes['postal_code'], NULL, NULL), 'country' => array(ts('Country'), $attributes['country_id'], 'country', FALSE), 'state_province' => array(ts('State/Province'), $attributes['state_province_id'], 'stateProvince', TRUE), 'county' => array(ts('County'), $attributes['county_id'], 'county', TRUE), 'address_name' => array(ts('Address Name'), $attributes['address_name'], NULL, NULL), 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL, NULL), 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL, NULL), 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL, NULL));
$parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', $addressOptions, 0);
$form->assign('parseStreetAddress', $parseStreetAddress);
foreach ($elements as $name => $v) {
list($title, $attributes, $select, $multiSelect) = $v;
if (in_array($name, array('street_number', 'street_name', 'street_unit'))) {
if (!$parseStreetAddress) {
continue;
}
} elseif (!$addressOptions[$name]) {
continue;
}
if (!$attributes) {
$attributes = $attributes[$name];
}
if ($select) {
if ($select == 'stateProvince' || $select == 'county') {
$element = $form->addChainSelect($name);
} else {
$selectElements = array('' => ts('- any -')) + CRM_Core_PseudoConstant::$select();
$element = $form->add('select', $name, $title, $selectElements, FALSE, array('class' => 'crm-select2'));
}
if ($multiSelect) {
$element->setMultiple(TRUE);
}
} else {
$form->addElement('text', $name, $title, $attributes);
}
if ($addressOptions['postal_code']) {
$attr = array('class' => 'six') + (array) CRM_Utils_Array::value('postal_code', $attributes);
$form->addElement('text', 'postal_code_low', NULL, $attr + array('placeholder' => ts('From')));
$form->addElement('text', 'postal_code_high', NULL, $attr + array('placeholder' => ts('To')));
}
}
// extend addresses with proximity search
if (!empty($config->geocodeMethod)) {
$form->addElement('text', 'prox_distance', ts('Find contacts within'), array('class' => 'six'));
$form->addElement('select', 'prox_distance_unit', NULL, array('miles' => ts('Miles'), 'kilos' => ts('Kilometers')));
$form->addRule('prox_distance', ts('Please enter positive number as a distance'), 'numeric');
}
$form->addSelect('world_region', array('entity' => 'address', 'context' => 'search'));
// select for location type
$locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$form->add('select', 'location_type', ts('Address Location'), $locationType, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => ts('Primary')));
// custom data extending addresses -
$extends = array('Address');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('addressGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$elementName = 'custom_' . $field['id'];
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $field['id'], FALSE, FALSE, TRUE);
}
}
}
}