Skip to content

Commit

Permalink
Switch priceset selector to addField method
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jul 19, 2019
1 parent a6c9f40 commit a0a2c91
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CRM/Contribute/Form/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
13 changes: 7 additions & 6 deletions CRM/Contribute/Form/ContributionPage/Amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
12 changes: 6 additions & 6 deletions CRM/Event/Form/ManageEvent/Fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
8 changes: 7 additions & 1 deletion CRM/Member/Form/MembershipBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
7 changes: 5 additions & 2 deletions CRM/Price/DAO/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Price/PriceSet.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:b8036fb0c2f5ad76f8f3bdf93f9db0f0)
* (GenCodeChecksum:2465848603f66c170842a63e347ab3e7)
*/

/**
Expand Down Expand Up @@ -154,14 +154,17 @@ 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',
'table_name' => 'civicrm_price_set',
'entity' => 'PriceSet',
'bao' => 'CRM_Price_BAO_PriceSet',
'localizable' => 0,
'html' => [
'type' => 'Select',
],
],
'domain_id' => [
'name' => 'domain_id',
Expand Down
5 changes: 4 additions & 1 deletion xml/schema/Price/PriceSet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit a0a2c91

Please sign in to comment.