From ab5e0c4102d3becfaae8aecc5be569cc0dadf35b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 29 Apr 2014 11:21:42 -0700 Subject: [PATCH] CRM-14181 - Cleanup membership form --- CRM/Core/SelectValues.php | 12 ++++-------- CRM/Member/Form/MembershipType.php | 20 ++++---------------- templates/CRM/Member/Form/MembershipType.tpl | 6 +++--- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 3fe65f4557..54ad9cdcfa 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -131,14 +131,10 @@ class CRM_Core_SelectValues { * @static */ static function memberVisibility() { - static $visible = NULL; - if (!$visible) { - $visible = array( - 'Public' => ts('Public'), - 'Admin' => ts('Admin'), - ); - } - return $visible; + return array( + 'Public' => ts('Public'), + 'Admin' => ts('Admin'), + ); } /** diff --git a/CRM/Member/Form/MembershipType.php b/CRM/Member/Form/MembershipType.php index 572c226e0c..479ee08f41 100644 --- a/CRM/Member/Form/MembershipType.php +++ b/CRM/Member/Form/MembershipType.php @@ -132,10 +132,10 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form { ); $this->addRule('minimum_fee', ts('Please enter a monetary value for the Minimum Fee.'), 'money'); - $this->addElement('select', 'duration_unit', ts('Duration'), CRM_Core_SelectValues::membershipTypeUnitList()); + $this->addSelect('duration_unit', array('placeholder' => NULL), TRUE); //period type - $this->addElement('select', 'period_type', ts('Period Type'), CRM_Core_SelectValues::periodType()); + $this->addSelect('period_type', array(), TRUE); $this->add('text', 'duration_interval', ts('Duration Interval'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'duration_interval') @@ -170,7 +170,7 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form { ); $this->add('select', 'financial_type_id', ts( 'Financial Type' ), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType() + array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), TRUE, array('class' => 'crm-select2') ); $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE); @@ -181,7 +181,7 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form { array('' => ts('- select -')) + $relTypeInd); $memberRel->setMultiple(TRUE); - $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::memberVisibility()); + $this->addSelect('visibility', array('placeholder' => NULL, 'option_url' => NULL)); $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'weight') ); @@ -224,18 +224,10 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form { $errors['name'] = ts('Please enter a membership type name.'); } - if (empty( $params['financial_type_id'] ) ) { - $errors['financial_type_id'] = ts('Please enter a financial type.'); - } - if (($params['minimum_fee'] > 0 ) && !$params['financial_type_id'] ) { $errors['financial_type_id'] = ts('Please enter the financial type.'); } - if (empty($params['duration_unit'])) { - $errors['duration_unit'] = ts('Please enter a duration unit.'); - } - if (empty($params['duration_interval']) and $params['duration_unit'] != 'lifetime') { $errors['duration_interval'] = ts('Please enter a duration interval.'); } @@ -249,10 +241,6 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form { } } - if (empty($params['period_type'])) { - $errors['period_type'] = ts('Please select a period type.'); - } - if ($params['period_type'] == 'fixed' && $params['duration_unit'] == 'day' ) { diff --git a/templates/CRM/Member/Form/MembershipType.tpl b/templates/CRM/Member/Form/MembershipType.tpl index f8d80fe46e..689df9e913 100644 --- a/templates/CRM/Member/Form/MembershipType.tpl +++ b/templates/CRM/Member/Form/MembershipType.tpl @@ -65,7 +65,7 @@ - {$form.financial_type_id.label} * + {$form.financial_type_id.label} {$form.financial_type_id.html}
{ts}Select the financial type assigned to fees for this membership type (for example 'Membership Fees'). This is required for all membership types - including free or complimentary memberships.{/ts} @@ -79,13 +79,13 @@ {/if} - {$form.duration_unit.label} * + {$form.duration_unit.label} {$form.duration_interval.html}  {$form.duration_unit.html}
{ts}Duration of this membership (e.g. 30 days, 2 months, 5 years, 1 lifetime){/ts} - {$form.period_type.label} * + {$form.period_type.label} {$form.period_type.html}
{ts}Select 'rolling' if membership periods begin at date of signup. Select 'fixed' if membership periods begin on a set calendar date.{/ts} {help id="period-type" file="CRM/Member/Page/MembershipType.hlp"} -- 2.25.1