当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Form::add方法代码示例

本文整理汇总了PHP中CRM_Core_Form::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::add方法的具体用法?PHP CRM_Core_Form::add怎么用?PHP CRM_Core_Form::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Form的用法示例。


在下文中一共展示了CRM_Core_Form::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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'));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:33,代码来源:ActivitySearch.php

示例2: 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'));
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:28,代码来源:ContributionAggregate.php

示例3: 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)'));
 }
开发者ID:Kajakaran,项目名称:org.civicoop.civirules,代码行数:7,代码来源:XWeekDay.php

示例4: buildForm

 /**
  * Build form.
  *
  * @param CRM_Core_Form $form
  */
 public static function buildForm(&$form)
 {
     // We should not build form elements in dashlet mode.
     if ($form->_section) {
         return;
     }
     // Check role based permission.
     $instanceID = $form->getVar('_id');
     if ($instanceID && !CRM_Report_Utils_Report::isInstanceGroupRoleAllowed($instanceID)) {
         $url = CRM_Utils_System::url('civicrm/report/list', 'reset=1');
         CRM_Core_Error::statusBounce(ts('You do not have permission to access this report.'), $url);
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Report_DAO_ReportInstance');
     $form->add('text', 'title', ts('Report Title'), $attributes['title']);
     $form->add('text', 'description', ts('Report Description'), $attributes['description']);
     $form->add('text', 'email_subject', ts('Subject'), $attributes['email_subject']);
     $form->add('text', 'email_to', ts('To'), $attributes['email_to']);
     $form->add('text', 'email_cc', ts('CC'), $attributes['email_subject']);
     $form->add('number', 'row_count', ts('Limit Dashboard Results'), array('class' => 'four', 'min' => 1));
     $form->add('textarea', 'report_header', ts('Report Header'), $attributes['header']);
     $form->add('textarea', 'report_footer', ts('Report Footer'), $attributes['footer']);
     $form->addElement('checkbox', 'is_navigation', ts('Include Report in Navigation Menu?'), NULL, array('onclick' => "return showHideByValue('is_navigation','','navigation_menu','table-row','radio',false);"));
     $form->addElement('select', 'view_mode', ts('Configure link to...'), array('view' => ts('View Results'), 'criteria' => ts('Show Criteria')));
     $form->addElement('checkbox', 'addToDashboard', ts('Available for Dashboard?'));
     $form->add('number', 'cache_minutes', ts('Cache dashlet for'), array('class' => 'four', 'min' => 1));
     $form->addElement('checkbox', 'add_to_my_reports', ts('Add to My Reports?'), NULL);
     $form->addElement('checkbox', 'is_reserved', ts('Reserved Report?'));
     if (!CRM_Core_Permission::check('administer reserved reports')) {
         $form->freeze('is_reserved');
     }
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework != 'Joomla' || $config->userFramework != 'WordPress') {
         $form->addElement('select', 'permission', ts('Permission'), array('0' => ts('Everyone (includes anonymous)')) + CRM_Core_Permission::basicPermissions());
         // prepare user_roles to save as names not as ids
         if (function_exists('user_roles')) {
             $user_roles_array = user_roles();
             foreach ($user_roles_array as $key => $value) {
                 $user_roles[$value] = $value;
             }
             $grouprole =& $form->addElement('advmultiselect', 'grouprole', ts('ACL Group/Role'), $user_roles, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
             $grouprole->setButtonAttributes('add', array('value' => ts('Add >>')));
             $grouprole->setButtonAttributes('remove', array('value' => ts('<< Remove')));
         }
     }
     // navigation field
     $parentMenu = CRM_Core_BAO_Navigation::getNavigationList();
     $form->add('select', 'parent_id', ts('Parent Menu'), array('' => ts('- select -')) + $parentMenu);
     // For now we only providing drilldown for one primary detail report only. In future this could be multiple reports
     foreach ($form->_drilldownReport as $reportUrl => $drillLabel) {
         $instanceList = CRM_Report_Utils_Report::getInstanceList($reportUrl);
         if (count($instanceList) > 1) {
             $form->add('select', 'drilldown_id', $drillLabel, array('' => ts('- select -')) + $instanceList);
         }
         break;
     }
     $form->addButtons(array(array('type' => 'submit', 'name' => ts('Save Report'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $form->addFormRule(array('CRM_Report_Form_Instance', 'formRule'), $form);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:63,代码来源:Instance.php

示例5: 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'));
 }
开发者ID:CiviCooP,项目名称:no.maf.postnummer,代码行数:17,代码来源:Postnummer.php

示例6: 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'), '&nbsp;');
     // 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']);
         }
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:60,代码来源:CommunicationPreferences.php

示例7: 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'));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:RandomSegment.php

示例8: 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'));
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:17,代码来源:ZipCodeRange.php

示例9: 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'));
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:24,代码来源:CSV.php

示例10: buildForm

 /**
  * Prepare a set of search fields
  *
  * @param CRM_Core_Form $form modifiable
  * @return void
  */
 function buildForm(&$form)
 {
     $config = CRM_Earmarking_Config::singleton();
     CRM_Utils_System::setTitle($config->translate('Search for Contacts with Recurring Contributions'));
     $paymentTypeList = $this->getPaymentTypeList();
     $earmarkingList = $this->getEarmarkingList();
     $contibutionStatusList = $this->getContributionStatusList();
     $form->add('select', 'earmarking_id', $config->translate('Earmarking'), $earmarkingList);
     $form->add('select', 'payment_type_id', $config->translate('Payment Type'), $paymentTypeList);
     $form->add('select', 'status_id', ts('Contribution Status'), $contibutionStatusList);
     $form->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'custom'));
     $form->assign('elements', array('earmarking_id', 'payment_type_id', 'status_id', 'start_date', 'end_date'));
 }
开发者ID:CiviCooP,项目名称:no.maf.earmarking,代码行数:20,代码来源:EarmarkSearch.php

示例11: 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'));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:Basic.php

示例12: buildForm

 /**
  * Prepare a set of search fields
  *
  * @param CRM_Core_Form $form modifiable
  * @return void
  */
 function buildForm(&$form)
 {
     CRM_Utils_System::setTitle(ts('Search for Players on Teams'));
     $form->add('text', 'contact_id', ts('Player ID'), TRUE);
     $form->add('text', 'group_id', ts('Team ID'), TRUE);
     //$team = array('' => ts('- any team -')) + CRM_Core_PseudoConstant::stateProvince();
     //$form->addElement('select', 'group_id', ts('Team'), $team);
     // Optionally define default search values
     $form->setDefaults(array('contact_id' => '', 'group_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('contact_id', 'group_id'));
 }
开发者ID:agloa,项目名称:tournament,代码行数:21,代码来源:Teams.php

示例13: buildForm

 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     foreach ($this->_amounts as $name => $title) {
         $form->add('text', $name, $title);
     }
     foreach ($this->_dates as $name => $title) {
         $form->addDate($name, $title, FALSE, array('formatType' => 'custom'));
     }
     foreach ($this->_checkboxes as $name => $title) {
         $form->add('checkbox', $name, $title);
     }
     $this->setTitle('Contributions made in Year X and not Year Y');
     // @TODO: Decide on better names for "Exclusion"
     // @TODO: Add rule to ensure that exclusion dates are not in the inclusion range
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:18,代码来源:ContribSYBNT.php

示例14: 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' );
 }
开发者ID:kidaa30,项目名称:yes,代码行数:35,代码来源:Phone.php

示例15: 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']);
     }
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:33,代码来源:MultipleValues.php


注:本文中的CRM_Core_Form::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。