Merge pull request #11657 from eileenmcnaughton/more_speed
[civicrm-core.git] / CRM / Profile / Form / Dynamic.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7e9e8871 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
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
8c9251b3 31 * @copyright CiviCRM LLC (c) 2004-2018
6a488035
TO
32 *
33 */
34
35/**
36 * This class generates form components for custom data
37 *
38 * It delegates the work to lower level subclasses and integrates the changes
39 * back in. It also uses a lot of functionality with the CRM API's, so any change
40 * made here could potentially affect the API etc. Be careful, be aware, use unit tests.
41 *
42 */
43class CRM_Profile_Form_Dynamic extends CRM_Profile_Form {
44
45 /**
100fef9d 46 * Pre processing work done here.
6a488035
TO
47 *
48 * @param
49 *
6a488035 50 */
00be9182 51 public function preProcess() {
6a488035
TO
52 if ($this->get('register')) {
53 $this->_mode = CRM_Profile_Form::MODE_REGISTER;
54 }
55 else {
56 $this->_mode = CRM_Profile_Form::MODE_EDIT;
57 }
58
59 if ($this->get('skipPermission')) {
60 $this->_skipPermission = TRUE;
61 }
62
63 // also allow dupes to be updated for edit in my account (CRM-2232)
64 $this->_isUpdateDupe = TRUE;
65
66 parent::preProcess();
67 }
68
69 /**
fe482240 70 * Build the form object.
6a488035 71 *
6a488035
TO
72 */
73 public function buildQuickForm() {
74 $this->addButtons(array(
c5c263ca
AH
75 array(
76 'type' => 'upload',
77 'name' => ts('Save'),
78 'isDefault' => TRUE,
79 ),
80 ));
6a488035
TO
81
82 // also add a hidden element for to trick drupal
83 $this->addElement('hidden', "edit[civicrm_dummy_field]", "CiviCRM Dummy Field for Drupal");
84 parent::buildQuickForm();
85
86 $this->addFormRule(array('CRM_Profile_Form_Dynamic', 'formRule'), $this);
87 }
88
89 /**
fe482240 90 * Global form rule.
6a488035 91 *
68c9fb83
TO
92 * @param array $fields
93 * The input form values.
94 * @param array $files
95 * The uploaded files if any.
c490a46a 96 * @param CRM_Core_Form $form
77b97be7 97 *
6a488035 98 *
72b3a70c
CW
99 * @return bool|array
100 * true if no errors, else array of errors
6a488035 101 */
00be9182 102 public static function formRule($fields, $files, $form) {
6a488035
TO
103 $errors = array();
104
105 // if no values, return
8cc574cf 106 if (empty($fields) || empty($fields['edit'])) {
6a488035
TO
107 return TRUE;
108 }
109
110 return CRM_Profile_Form::formRule($fields, $files, $form);
111 }
112
113 /**
114 * Process the user submitted custom data values.
6a488035
TO
115 */
116 public function postProcess() {
117 parent::postProcess();
118 }
96025800 119
6a488035 120}