From a0a2c91da774c540ad859c2c73df669a3cdf4a32 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Fri, 19 Jul 2019 16:59:03 +0100 Subject: [PATCH] Switch priceset selector to addField method --- CRM/Contribute/Form/ContributionPage.php | 7 +++++++ CRM/Contribute/Form/ContributionPage/Amount.php | 13 +++++++------ CRM/Event/Form/ManageEvent/Fee.php | 12 ++++++------ CRM/Member/Form/MembershipBlock.php | 8 +++++++- CRM/Price/DAO/PriceSet.php | 7 +++++-- xml/schema/Price/PriceSet.xml | 5 ++++- 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index c965e60d1ca5..f1490ee44cee 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -87,6 +87,13 @@ public function getDefaultEntity() { return 'Contribution'; } + /** + * Explicitly declare the form context. + */ + public function getDefaultContext() { + return 'create'; + } + /** * Set variables up before form is built. */ diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index 29fdd78efeca..538569eb2cb7 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -152,12 +152,13 @@ public function buildQuickForm() { else { $this->assign('price', TRUE); } - $this->add('select', 'price_set_id', ts('Price Set'), - [ - '' => ts('- none -'), - ] + $price, - NULL, ['onchange' => "showHideAmountBlock( this.value, 'price_set_id' );"] - ); + + $this->addField('price_set_id', [ + 'entity' => 'PriceSet', + 'options' => $price, + 'onchange' => "showHideAmountBlock( this.value, 'price_set_id' );", + ]); + //CiviPledge fields. $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents)) { diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index 46420b809a33..16572e178d7b 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -290,12 +290,12 @@ public function buildQuickForm() { else { $this->assign('price', TRUE); } - $this->add('select', 'price_set_id', ts('Price Set'), - [ - '' => ts('- none -'), - ] + $price, - NULL, ['onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);"] - ); + $this->addField('price_set_id', [ + 'entity' => 'PriceSet', + 'options' => $price, + 'onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);", + ]); + $default = [$this->createElement('radio', NULL, NULL, NULL, 0)]; $this->add('hidden', 'price_field_id', '', ['id' => 'price_field_id']); for ($i = 1; $i <= self::NUM_OPTION; $i++) { diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index 83df3d77a151..04eb474ebb95 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -189,7 +189,13 @@ public function buildQuickForm() { else { $this->assign('price', TRUE); } - $this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price)); + //$this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price)); + + $this->addField('member_price_set_id', [ + 'entity' => 'PriceSet', + 'name' => 'price_set_id', + 'options' => $price, + ]); $session = CRM_Core_Session::singleton(); $single = $session->get('singleForm'); diff --git a/CRM/Price/DAO/PriceSet.php b/CRM/Price/DAO/PriceSet.php index f6eeeb91db8d..a4b704dd7a1a 100644 --- a/CRM/Price/DAO/PriceSet.php +++ b/CRM/Price/DAO/PriceSet.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Price/PriceSet.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:b8036fb0c2f5ad76f8f3bdf93f9db0f0) + * (GenCodeChecksum:2465848603f66c170842a63e347ab3e7) */ /** @@ -154,7 +154,7 @@ public static function &fields() { 'id' => [ 'name' => 'id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Price Set ID'), + 'title' => ts('Price Set'), 'description' => ts('Price Set'), 'required' => TRUE, 'where' => 'civicrm_price_set.id', @@ -162,6 +162,9 @@ public static function &fields() { 'entity' => 'PriceSet', 'bao' => 'CRM_Price_BAO_PriceSet', 'localizable' => 0, + 'html' => [ + 'type' => 'Select', + ], ], 'domain_id' => [ 'name' => 'domain_id', diff --git a/xml/schema/Price/PriceSet.xml b/xml/schema/Price/PriceSet.xml index 27b8852eb932..25266f1dbfc4 100644 --- a/xml/schema/Price/PriceSet.xml +++ b/xml/schema/Price/PriceSet.xml @@ -8,11 +8,14 @@ true id - Price Set ID + Price Set int unsigned true Price Set 1.8 + + Select + id