CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Multiple contact subtypes with custom fields
Pages: [1]

Author Topic: Multiple contact subtypes with custom fields  (Read 1044 times)

ThomWilhelm

  • I’m new here
  • *
  • Posts: 10
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5
Multiple contact subtypes with custom fields
November 19, 2012, 04:49:18 am
I think this might be a bug, I have the following setup in Civi. I am running Civi 4.2.6 for Drupal 7.

"Contact"
"Contact Subtype A"
"Contact Subtype B"

Both of the contact subtypes have their own custom fields which are used only for that subtype. When a contact is defined as both "Contact Subtype A" and "Contact Subtype B", on the view screen for the contact all custom fields are shown for both the subtypes.

However when you edit the contact neither sets of the custom fields are shown. If you make the contact of only a single subtype, the custom fields are shown correctly when you edit, however if you add both neither are shown just when you edit.

I'm trying to find in the codebase where it decides to show/hide fields when you edit a contact, can anyone point me in the right direction? I'm assuming this is a bug at this stage.

Cheers.

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Multiple contact subtypes with custom fields
November 19, 2012, 06:01:41 am
Yep, verified. Its a bug. Filed an issue here - http://issues.civicrm.org/jira/browse/CRM-11307.

If you can investigate further & submit a patch would be great.

You could start with CRM/Contact/Form/Contact.php look for code with custom keywords, and drill down. templates/CRM/Contact/Form/Contact.tpl would have the code for loading custom fields when form is loaded.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

ThomWilhelm

  • I’m new here
  • *
  • Posts: 10
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5
Re: Multiple contact subtypes with custom fields
November 19, 2012, 06:25:51 am
Ok thanks I'll see if I can work out why this is happening, thanks for the advice over where to start looking.

Just on your bug report I wouldn't agree this is a trivial issue "Cosmetic problem like misspelt words or misaligned text.".

I'd say not being able to edit a Contacts data is more than a cosmetic problem.

Cheers.

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Multiple contact subtypes with custom fields
November 19, 2012, 06:37:57 am
Agree updated the priority flag to critical. That was a default setting.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

ThomWilhelm

  • I’m new here
  • *
  • Posts: 10
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5
Re: Multiple contact subtypes with custom fields
November 19, 2012, 07:29:45 am
Still working backwards on how the data is loaded with this page, but I can see that in the following template:

templates/CRM/Custom/Form/Edit/CustomData.tpl

The $groupTree array is empty when multiple contact subtypes are selected, when only a single subtype is selected, this array is populated correctly. Am now trying to determine where this comes from, and why it's not working in this instance.

ThomWilhelm

  • I’m new here
  • *
  • Posts: 10
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5
Re: Multiple contact subtypes with custom fields
November 19, 2012, 08:17:37 am
I've worked out where this originates from (probably don't understand the full background of why this broke etc).

Inside CRM/Custom/Form/CustomData.php

Around line 96 there is the following:

Code: [Select]
$groupTree = &CRM_Core_BAO_CustomGroup::getTree($form->_type,
   $form,
   $form->_entityId,
   $form->_groupID,
   $form->_subType,
   $form->_subName
);

The $form->_subType attribute is a string where each subtype is split with a "^A" character, this is only the case when multiple contact subtypes are selected. This is then passed into CRM/Core/BAO/CustomGroup.php which doesn't seem to handle strings split with this characters (however it does seem to expect/handle an array).

I've submitted a patch which will fix this, although I'm still having a bit more of a look at how this all works (I'm new to Civi), so any improvements/suggestions are welcome. :)

Cheers,
Thom.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Multiple contact subtypes with custom fields
November 20, 2012, 03:43:44 am
might be related: http://forum.civicrm.org/index.php/topic,26802.0.html
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Multiple contact subtypes with custom fields

This forum was archived on 2017-11-26.