Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
f299f7db | 31 | * @copyright CiviCRM LLC (c) 2004-2020 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
3ecad08a | 35 | * Form helper class for an Demographics object. |
6a488035 TO |
36 | */ |
37 | class CRM_Contact_Form_Edit_CustomData { | |
38 | ||
39 | /** | |
fe482240 | 40 | * Build all the data structures needed to build the form. |
6a488035 | 41 | * |
c490a46a | 42 | * @param CRM_Core_Form $form |
6a488035 | 43 | */ |
00be9182 | 44 | public static function preProcess(&$form) { |
a3d827a7 CW |
45 | $form->_type = CRM_Utils_Request::retrieve('type', 'String'); |
46 | $form->_subType = CRM_Utils_Request::retrieve('subType', 'String'); | |
6a488035 TO |
47 | |
48 | //build the custom data as other blocks. | |
49 | //$form->assign( "addBlock", false ); | |
50 | if ($form->_type) { | |
51 | $form->_addBlockName = 'CustomData'; | |
52 | $form->assign("addBlock", TRUE); | |
53 | $form->assign("blockName", $form->_addBlockName); | |
54 | } | |
55 | ||
56 | CRM_Custom_Form_CustomData::preProcess($form, NULL, $form->_subType, NULL, | |
57 | ($form->_type) ? $form->_type : $form->_contactType | |
58 | ); | |
59 | ||
60 | //assign group tree after build. | |
61 | $form->assign('groupTree', $form->_groupTree); | |
62 | } | |
63 | ||
64 | /** | |
fe482240 | 65 | * Build the form object elements for CustomData object. |
6a488035 | 66 | * |
77c5b619 TO |
67 | * @param CRM_Core_Form $form |
68 | * Reference to the form object. | |
6a488035 | 69 | */ |
00be9182 | 70 | public static function buildQuickForm(&$form) { |
22e263ad | 71 | if (!empty($form->_submitValues)) { |
6a488035 TO |
72 | if ($customValueCount = CRM_Utils_Array::value('hidden_custom_group_count', $form->_submitValues)) { |
73 | if (is_array($customValueCount)) { | |
74 | if (array_key_exists(0, $customValueCount)) { | |
75 | unset($customValueCount[0]); | |
76 | } | |
77 | $form->_customValueCount = $customValueCount; | |
481a74f4 | 78 | $form->assign('customValueCount', $customValueCount); |
6a488035 TO |
79 | } |
80 | } | |
81 | } | |
82 | CRM_Custom_Form_CustomData::buildQuickForm($form); | |
83 | ||
84 | //build custom data. | |
85 | $contactSubType = NULL; | |
8cc574cf | 86 | if (!empty($_POST["hidden_custom"]) && !empty($_POST['contact_sub_type'])) { |
6a488035 TO |
87 | $contactSubType = $_POST['contact_sub_type']; |
88 | } | |
89 | else { | |
90 | $contactSubType = CRM_Utils_Array::value('contact_sub_type', $form->_values); | |
91 | } | |
92 | $form->assign('contactType', $form->_contactType); | |
93 | $form->assign('contactSubType', $contactSubType); | |
94 | } | |
95 | ||
96 | /** | |
c490a46a | 97 | * Set default values for the form. Note that in edit/view mode |
6a488035 TO |
98 | * the default values are retrieved from the database |
99 | * | |
6a488035 | 100 | * |
c490a46a | 101 | * @param CRM_Core_Form $form |
c037736a | 102 | * @param array $defaults |
6a488035 | 103 | */ |
00be9182 | 104 | public static function setDefaultValues(&$form, &$defaults) { |
6a488035 TO |
105 | $defaults += CRM_Custom_Form_CustomData::setDefaultValues($form); |
106 | } | |
96025800 | 107 | |
6a488035 | 108 | } |