Skip to content

Commit 3a6012d

Browse files
Merge pull request #14843 from mattwire/priceset_to_metadatafield
Switch priceset selector to addField method
2 parents d4af0c9 + a0a2c91 commit 3a6012d

6 files changed

Lines changed: 36 additions & 16 deletions

File tree

CRM/Contribute/Form/ContributionPage.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ public function getDefaultEntity() {
8787
return 'Contribution';
8888
}
8989

90+
/**
91+
* Explicitly declare the form context.
92+
*/
93+
public function getDefaultContext() {
94+
return 'create';
95+
}
96+
9097
/**
9198
* Set variables up before form is built.
9299
*/

CRM/Contribute/Form/ContributionPage/Amount.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ public function buildQuickForm() {
152152
else {
153153
$this->assign('price', TRUE);
154154
}
155-
$this->add('select', 'price_set_id', ts('Price Set'),
156-
[
157-
'' => ts('- none -'),
158-
] + $price,
159-
NULL, ['onchange' => "showHideAmountBlock( this.value, 'price_set_id' );"]
160-
);
155+
156+
$this->addField('price_set_id', [
157+
'entity' => 'PriceSet',
158+
'options' => $price,
159+
'onchange' => "showHideAmountBlock( this.value, 'price_set_id' );",
160+
]);
161+
161162
//CiviPledge fields.
162163
$config = CRM_Core_Config::singleton();
163164
if (in_array('CiviPledge', $config->enableComponents)) {

CRM/Event/Form/ManageEvent/Fee.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ public function buildQuickForm() {
290290
else {
291291
$this->assign('price', TRUE);
292292
}
293-
$this->add('select', 'price_set_id', ts('Price Set'),
294-
[
295-
'' => ts('- none -'),
296-
] + $price,
297-
NULL, ['onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);"]
298-
);
293+
$this->addField('price_set_id', [
294+
'entity' => 'PriceSet',
295+
'options' => $price,
296+
'onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);",
297+
]);
298+
299299
$default = [$this->createElement('radio', NULL, NULL, NULL, 0)];
300300
$this->add('hidden', 'price_field_id', '', ['id' => 'price_field_id']);
301301
for ($i = 1; $i <= self::NUM_OPTION; $i++) {

CRM/Member/Form/MembershipBlock.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ public function buildQuickForm() {
189189
else {
190190
$this->assign('price', TRUE);
191191
}
192-
$this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price));
192+
//$this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price));
193+
194+
$this->addField('member_price_set_id', [
195+
'entity' => 'PriceSet',
196+
'name' => 'price_set_id',
197+
'options' => $price,
198+
]);
193199

194200
$session = CRM_Core_Session::singleton();
195201
$single = $session->get('singleForm');

CRM/Price/DAO/PriceSet.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Generated from xml/schema/CRM/Price/PriceSet.xml
88
* DO NOT EDIT. Generated by CRM_Core_CodeGen
9-
* (GenCodeChecksum:b8036fb0c2f5ad76f8f3bdf93f9db0f0)
9+
* (GenCodeChecksum:2465848603f66c170842a63e347ab3e7)
1010
*/
1111

1212
/**
@@ -154,14 +154,17 @@ public static function &fields() {
154154
'id' => [
155155
'name' => 'id',
156156
'type' => CRM_Utils_Type::T_INT,
157-
'title' => ts('Price Set ID'),
157+
'title' => ts('Price Set'),
158158
'description' => ts('Price Set'),
159159
'required' => TRUE,
160160
'where' => 'civicrm_price_set.id',
161161
'table_name' => 'civicrm_price_set',
162162
'entity' => 'PriceSet',
163163
'bao' => 'CRM_Price_BAO_PriceSet',
164164
'localizable' => 0,
165+
'html' => [
166+
'type' => 'Select',
167+
],
165168
],
166169
'domain_id' => [
167170
'name' => 'domain_id',

xml/schema/Price/PriceSet.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
<log>true</log>
99
<field>
1010
<name>id</name>
11-
<title>Price Set ID</title>
11+
<title>Price Set</title>
1212
<type>int unsigned</type>
1313
<required>true</required>
1414
<comment>Price Set</comment>
1515
<add>1.8</add>
16+
<html>
17+
<type>Select</type>
18+
</html>
1619
</field>
1720
<primaryKey>
1821
<name>id</name>

0 commit comments

Comments
 (0)