Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-16301

'The Contact Sub Type does not match the Contact type for this record' when saving a new contact

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5.8
    • Fix Version/s: 4.6.3
    • Component/s: None
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      Clicking 'Save and New' when editing a contact which has one or more subtypes - the variable $this->_contactSubType is appended to the URL. However, in this flow that variable is delimited w/ ASCII 01 character, which results in the behavior described below.

      (see line 1041 in CRM_Contact_Form_Contact::postProcess)

      Fix this by:

      • check length of $this->_contactSubType list (can be 0, 1 or more since contacts may have multiple subtypes)
      • If $this->_contactSubType list length = 1, trim out the delimiters and append to the URL as we do now
      • If $this->_contactSubType list length > 1, do not append to URL (we do not support loading of Add Contact form with multiple subtypes passed via URL).

      ---- Original Post ----
      Steps to reproduce:

      • Create a new Contact sub Type 'Student' of 'Individual'
      • Create a new Contact with the new sub Type and save.
      • From the view page, edit the same contact and use "Save and New"

      The URL of this last page will have:

      http://<domain>/civicrm/contact/add?reset=1&ct=Individual&cst=%01Student%01

      and when attempting to Save generates the error.

      Edit: after some extra digging, I discovered that all the 'Student' contacts in the database had `contact_sub_type`='%01Student%01' (urlencoded values added for clarity).
      Still, the civicrm_contact_type table has only 'Student'.

        Attachments

          Activity

            People

            • Assignee:
              rohan1990 Rohan Ramesh Katkar
              Reporter:
              savedario Dario Savella
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: