3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * form helper class for an Demographics object
39 class CRM_Contact_Form_Edit_CustomData
{
42 * build all the data structures needed to build the form
47 static function preProcess(&$form) {
48 $form->_type
= CRM_Utils_Request
::retrieve('type', 'String', CRM_Core_DAO
::$_nullObject);
49 $form->_subType
= CRM_Utils_Request
::retrieve('subType', 'String', CRM_Core_DAO
::$_nullObject);
51 //build the custom data as other blocks.
52 //$form->assign( "addBlock", false );
54 $form->_addBlockName
= 'CustomData';
55 $form->assign("addBlock", TRUE);
56 $form->assign("blockName", $form->_addBlockName
);
59 CRM_Custom_Form_CustomData
::preProcess($form, NULL, $form->_subType
, NULL,
60 ($form->_type
) ?
$form->_type
: $form->_contactType
63 //assign group tree after build.
64 $form->assign('groupTree', $form->_groupTree
);
68 * build the form elements for CustomData object
70 * @param CRM_Core_Form $form reference to the form object
76 static function buildQuickForm(&$form) {
77 if(!empty($form->_submitValues
)) {
78 if ($customValueCount = CRM_Utils_Array
::value('hidden_custom_group_count', $form->_submitValues
)) {
79 if (is_array($customValueCount)) {
80 if (array_key_exists(0, $customValueCount)) {
81 unset($customValueCount[0]);
83 $form->_customValueCount
= $customValueCount;
84 $form->assign( 'customValueCount', $customValueCount);
88 CRM_Custom_Form_CustomData
::buildQuickForm($form);
91 $contactSubType = NULL;
92 if (!empty($_POST["hidden_custom"]) && !empty($_POST['contact_sub_type'])) {
93 $contactSubType = $_POST['contact_sub_type'];
96 $contactSubType = CRM_Utils_Array
::value('contact_sub_type', $form->_values
);
98 $form->assign('contactType', $form->_contactType
);
99 $form->assign('contactSubType', $contactSubType);
103 * This function sets the default values for the form. Note that in edit/view mode
104 * the default values are retrieved from the database
110 static function setDefaultValues(&$form, &$defaults) {
111 $defaults +
= CRM_Custom_Form_CustomData
::setDefaultValues($form);