Merge pull request #4692 from kurund/CRM-14696
[civicrm-core.git] / CRM / Contact / Form / RelatedContact.php
index 03edc2abfb854f16d5c5fcf49385c5f09b4d12a9..ec8a205936a4c01becae6ceb4d847c807326ba48 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -58,14 +58,14 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form {
   public $_contactId;
 
   /**
-   * form defaults
+   * Form defaults
    *
    * @var array
    */
   protected $_defaults = array();
 
   /**
-   * build all the data structures needed to build the form
+   * Build all the data structures needed to build the form
    *
    * @return void
    * @access public
@@ -104,21 +104,21 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form {
   }
 
   /**
-   * This function sets the default values for the form. Note that in edit/view mode
+   * Set default values for the form. Note that in edit/view mode
    * the default values are retrieved from the database
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   function setDefaultValues() {
     return $this->_defaults;
   }
 
   /**
-   * Function to actually build the form
+   * Build the form object
    *
-   * @return None
+   * @return void
    * @access public
    */
   public function buildQuickForm() {
@@ -161,7 +161,7 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   public function postProcess() {
     // store the submitted values in an array
@@ -181,6 +181,10 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form {
     }
 
     $params['contact_type'] = $this->_contactType;
+    //CRM-14904
+    if ( isset($this->_defaults['contact_sub_type']) ) {
+      $params['contact_sub_type'] = $this->_defaults['contact_sub_type'];
+    }
     $params['contact_id'] = $this->_contactId;
 
     $contact = CRM_Contact_BAO_Contact::create($params, TRUE);