CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'group' => 'contribute', 'name' => 'check_payment_instrument_ids', 'type' => 'Array', 'html_type' => 'Select', 'quick_form_type' => 'Select', 'html_attributes' => array( 'multiple' => 1, 'class' => 'crm-select2', ), 'pseudoconstant' => array( 'callback' => 'CRM_Contribute_BAO_CheckNumberPaymentMethod::getPaymentInstrument', ), 'default' => NULL, 'add' => '5.5', 'title' => ts('Check-Payment Instruments'), 'is_domain' => '1', 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, ]; } /** * Implements hook_civicrm_preProcess(). * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_preProcess */ function checknumberpaymentmethod_civicrm_preProcess($formName, &$form) { if ('CRM_Admin_Form_Preferences_Contribute' == $formName) { $vars = $form->getVar('_settings'); $vars['check_payment_instrument_ids'] = CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME; $form->setVar('_settings', $vars); $form->setVar('settingsMetadata', ''); } } /** * Implements hook_civicrm_preProcess(). * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_preProcess */ function checknumberpaymentmethod_civicrm_buildForm($formName, &$form) { if ('CRM_Admin_Form_Preferences_Contribute' == $formName) { $form->addElement( 'select', 'check_payment_instrument_ids', ts('Check-Payment Instruments'), CRM_Contribute_BAO_CheckNumberPaymentMethod::getPaymentInstrument(), [ 'multiple' => 1, 'class' => 'crm-select2', ] ); $form->assign('fields', $form->getVar('settingsMetadata')); } if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID)) { $paymentInstrumentsFromSettings = civicrm_api3('Setting', 'getvalue', [ 'name' => 'check_payment_instrument_ids', ]); if (in_array($form->paymentInstrumentID, $paymentInstrumentsFromSettings)) { $form->assign('paymentFields', array('check_number')); $form->add('text', 'check_number', ts('Check Number')); $form->assign('paymentTypeLabel', ts('Check Information')); } } }