Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use CRM_Otheramount_ExtensionUtil as E;
- /**
- * Form controller class
- *
- * @see https://wiki.civicrm.org/confluence/display/CRMDOC/QuickForm+Reference
- */
- class CRM_Otheramount_Form_OtherAmountSettings extends CRM_Core_Form {
- protected $_otherAmountPriceSets;
- /**
- * Set variables up before form is built.
- */
- public function preProcess() {
- if (!CRM_Core_Permission::check('administer CiviCRM')) {
- CRM_Core_Error::fatal(ts('You do not permission to access this page, please contact your system administrator.'));
- }
- $this->_otherAmountPriceSets = Civi::settings()->get('otherAmountPriceSets');
- }
- /**
- * Set default values.
- *
- * @return array
- */
- public function setDefaultValues() {
- return $this->_otherAmountPriceSets;
- }
- public function buildQuickForm() {
- //We want active price fields with HTML type radio in active price sets that aren't quick config
- $results = civicrm_api3('PriceSet', 'get', [
- 'sequential' => 1,
- 'return' => ["id"],
- 'is_quick_config' => 0,
- 'is_active' => 1,
- 'api.PriceField.get' => ['price_set_id' => "\$value.id", 'html_type' => "radio", 'return' => "id"],
- ]);
- $priceFieldIDs = array();
- foreach ($results['values'] as $result) {
- foreach ($result['api.PriceField.get']['values'] as $priceID) {
- array_push($priceFieldIDs, $priceID['id']);
- }
- }
- $this->addEntityRef('other_amount_price_fields', ts('Other Amount Price Fields'), array(
- 'entity' => 'PriceField',
- 'api' => array(
- 'params' => array(
- 'id' => ['IN' => $priceFieldIDs],
- ),
- ),
- 'select' => array('minimumInputLength' => 0),
- 'multiple' => TRUE,
- ));
- var_dump($this->_elements);
- $this->addButtons(array(
- array(
- 'type' => 'submit',
- 'name' => ts('Submit', array('domain' => 'com.domain.extension')),
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel', array('domain' => 'com.domain.extension')),
- ),
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement