Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Membership custom fields sometimes don't display #13411

Merged
merged 1 commit into from
Jan 7, 2019

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Jan 7, 2019

Overview

There is a very irritating issue to do with displaying custom fields in Memberships, where some custom field sets don't appear -- sometimes! So if you have Set 1, Set 2, and Set 3, you can edit a membership and sometimes Set 1 will be there and sometimes it won't.

I've just replicated this on the staging site. Here's how to do it:

  1. On a Wordpress or Drupal demo site, create three Custom Data sets. These should apply to Memberships. The first should apply to the 'Student' membership type, and the second and third should be for 'All' membership types. Let's say they're called Set 1, Set 2, and Set 3.

  2. Create a single field in each one.

  3. Create a Student membership on someone's record.

  4. Click edit on the membership, from the memberships tab. Do this repeatedly, then close the pop-up. Sometimes Set 1 will appear and sometimes it won't. (actually, I'm pretty sure it appears then disappears)

Before

Custom data is built twice, first without a customdata subtype and then with a customdata subtype. Depending on the speed of page load / order of execution customdata specific to a subtype may or may not be displayed.

After

Custom data is built once on the form. Either with a subtype or without a subtype as required.

Technical Details

This code was extracted relatively recently as part of efforts to improve custom data handling on forms. No changes were made at the time but the same code pattern appears in multiple places, sometimes with each CRM.buildCustomData wrapped in an if statement, sometimes no if statement for the first one - meaning it will run twice if the form has a subtype (eg membership_type, case_type).

Comments

@bhahumanists Are you able to confirm this fixes the issue?

@civibot
Copy link

civibot bot commented Jan 7, 2019

(Standard links)

@civibot civibot bot added the master label Jan 7, 2019
@@ -581,7 +581,7 @@ public function buildQuickForm() {
);

if (!empty($this->_recurPaymentProcessors)) {
$memTypeJs['onChange'] = "" . $memTypeJs['onChange'] . "buildAutoRenew(this.value, null, '{$this->_mode}');";
$memTypeJs['onChange'] = "" . $memTypeJs['onChange'] . " buildAutoRenew(this.value, null, '{$this->_mode}');";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the space I'm getting a console error when editing a membership that 'buildAutoRenew' is not defined.

@bhahumanists
Copy link
Contributor

Yes, initial testing suggests this has fixed it - thank you!

@colemanw
Copy link
Member

colemanw commented Jan 7, 2019

Code looks correct. Merging based on user testing and tests passing.

@colemanw colemanw merged commit 7bce01c into civicrm:master Jan 7, 2019
@mattwire mattwire deleted the fix_buildCustomDataTwice branch March 1, 2019 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants