Switch priceset selector to addField method
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 19 Jul 2019 15:59:03 +0000 (16:59 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 19 Jul 2019 16:04:52 +0000 (17:04 +0100)
CRM/Contribute/Form/ContributionPage.php
CRM/Contribute/Form/ContributionPage/Amount.php
CRM/Event/Form/ManageEvent/Fee.php
CRM/Member/Form/MembershipBlock.php
CRM/Price/DAO/PriceSet.php
xml/schema/Price/PriceSet.xml

index c965e60d1ca5b127f6195d8f1e048a0bdea87bb9..f1490ee44ceefb1942d03c7d6eed51df9b2b8e00 100644 (file)
@@ -87,6 +87,13 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form {
     return 'Contribution';
   }
 
+  /**
+   * Explicitly declare the form context.
+   */
+  public function getDefaultContext() {
+    return 'create';
+  }
+
   /**
    * Set variables up before form is built.
    */
index 29fdd78efeca3171dfc74b677d2301262b16089d..538569eb2cb784883ffd6f15df453d1ea00ff06e 100644 (file)
@@ -152,12 +152,13 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co
     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)) {
index 46420b809a33d9ac4eb5e017517f3a1097b3ac09..16572e178d7bb534c5e384bf0b757568bf4dd758 100644 (file)
@@ -290,12 +290,12 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent {
     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++) {
index 83df3d77a15191d6635b3dc4d62aa6b7f37c773b..04eb474ebb9517e2590ccb457758c45256cf5b4d 100644 (file)
@@ -189,7 +189,13 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa
     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');
index f6eeeb91db8dedf72950f3367a1f21df90d05bc7..a4b704dd7a1a083d01df480cbf22b32a907826b2 100644 (file)
@@ -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 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
         '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 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Select',
+          ],
         ],
         'domain_id' => [
           'name' => 'domain_id',
index 27b8852eb932c22a5a9bf78670a525808a335f3d..25266f1dbfc4380015787096eb272bd39386a04e 100644 (file)
@@ -8,11 +8,14 @@
   <log>true</log>
   <field>
     <name>id</name>
-    <title>Price Set ID</title>
+    <title>Price Set</title>
     <type>int unsigned</type>
     <required>true</required>
     <comment>Price Set</comment>
     <add>1.8</add>
+    <html>
+      <type>Select</type>
+    </html>
   </field>
   <primaryKey>
     <name>id</name>