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