Skip to content

Commit 04dba80

Browse files
committed
MembershipType - Show titles instead of name on admin page/form
1 parent 16dc8df commit 04dba80

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

CRM/Member/Form/MembershipType.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig {
3030
*/
3131
protected function setEntityFields() {
3232
$this->entityFields = [
33-
'name' => [
33+
'title' => [
3434
'required' => 'TRUE',
35-
'name' => 'name',
36-
'description' => ts("e.g. 'Student', 'Senior', 'Honor Society'..."),
35+
'name' => 'title',
36+
'description' => ts("Internal name, e.g. 'Student', 'Senior', 'Honor Society'..."),
37+
],
38+
'frontend_title' => [
39+
'required' => 'TRUE',
40+
'name' => 'frontend_title',
41+
'description' => ts('Name as shown on public pages.'),
3742
],
3843
'description' => [
3944
'name' => 'description',
@@ -225,11 +230,8 @@ public function buildQuickForm() {
225230
// Fields in this array have been tested & in the tpl have been switched over to metadata.
226231
// Note this kinda 'works from the top' - ie. once we hit a field that needs some thought we need
227232
// to stop & make that one work.
228-
$this->assign('tpl_standardised_fields', ['name', 'description', 'member_of_contact_id', 'minimum_fee']);
233+
$this->assign('tpl_standardised_fields', ['title', 'frontend_title', 'description', 'member_of_contact_id', 'minimum_fee']);
229234

230-
$this->addRule('name', ts('A membership type with this name already exists. Please select another name.'),
231-
'objectExists', ['CRM_Member_DAO_MembershipType', $this->_id]
232-
);
233235
$this->addRule('minimum_fee', ts('Please enter a monetary value for the Minimum Fee.'), 'money');
234236

235237
$props = ['api' => ['params' => ['contact_type' => 'Organization']]];
@@ -292,10 +294,6 @@ public function buildQuickForm() {
292294
public static function formRule($params) {
293295
$errors = [];
294296

295-
if (!$params['name']) {
296-
$errors['name'] = ts('Please enter a membership type name.');
297-
}
298-
299297
if (($params['minimum_fee'] > 0) && !$params['financial_type_id']) {
300298
$errors['financial_type_id'] = ts('Please enter the financial Type.');
301299
}

CRM/Member/Page/MembershipType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public function browse(): void {
101101
->setSelect([
102102
'id',
103103
'domain_id',
104-
'name',
104+
'title',
105+
'frontend_title',
105106
'fixed_period_start_day',
106107
'fixed_period_rollover_day',
107108
'max_related',

templates/CRM/Member/Page/MembershipType.tpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<thead>
2424
<tr>
2525
<th>{ts}Membership{/ts}</th>
26+
<th>{ts}Frontend Title{/ts}</th>
2627
<th>{ts}Period{/ts}</th>
2728
<th>{ts}Fixed Start{/ts}</th>
2829
<th>{ts}Minimum Fee{/ts}</th>
@@ -38,7 +39,8 @@
3839
</thead>
3940
{foreach from=$rows item=row}
4041
<tr id="membership_type-{$row.id}" class="crm-entity {cycle values='odd-row,even-row'} crm-membership-type {if NOT $row.is_active} disabled{/if}">
41-
<td class="crmf-name crm-editable" data-field="name">{$row.name}</td>
42+
<td class="crm-editable" data-field="title">{$row.title}</td>
43+
<td class="crm-editable" data-field="frontend_title">{$row.frontend_title}</td>
4244
<td class="crmf-period_type crm-editable" data-type="select">{$row.period_type}</td>
4345
<td class="crmf-fixed_period_start_day">{$row.fixed_period_start_day}</td>
4446
<td class="crmf-minimum_fee" align="right">{$row.minimum_fee|crmMoney}</td>
@@ -64,7 +66,7 @@
6466
{else}
6567
{if $action ne 1}
6668
<div class="messages status no-popup">
67-
{icon icon="fa-info-circle"}{/icon}
69+
{icon icon="fa-info-circle"}{/icon}
6870
{capture assign=crmURL}{crmURL p='civicrm/admin/member/membershipType/add' q="action=add&reset=1"}{/capture}{ts 1=$crmURL}There are no membership types entered. You can <a href='%1'>add one</a>.{/ts}
6971
</div>
7072
{/if}

tests/phpunit/CRM/Member/Page/MembershipTypeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public function testMembershipTypePage(): void {
3030
$id => [
3131
'id' => '1',
3232
'domain_id' => '1',
33-
'name' => 'General',
33+
'title' => 'General',
34+
'frontend_title' => 'General',
3435
'member_of_contact_id' => '3',
3536
'financial_type_id' => '2',
3637
'minimum_fee' => 0.0,

0 commit comments

Comments
 (0)