3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * This class is to build the form for Deleting Group
23 class CRM_Custom_Form_MoveField
extends CRM_Core_Form
{
54 * The title of the field being moved.
58 protected $_srcFieldLabel;
61 * Set up variables to build the form.
66 public function preProcess() {
67 $this->_srcFID
= CRM_Utils_Request
::retrieve('fid', 'Positive',
71 $this->_srcGID
= CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomField',
76 $this->_srcFieldLabel
= CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomField',
81 CRM_Utils_System
::setTitle(ts('Custom Field Move: %1',
82 [1 => $this->_srcFieldLabel
]
85 $session = CRM_Core_Session
::singleton();
86 $session->pushUserContext(CRM_Utils_System
::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_srcGID}"));
90 * Build the form object.
94 public function buildQuickForm() {
96 $customGroup = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_CustomField', 'custom_group_id');
97 unset($customGroup[$this->_srcGID
]);
98 if (empty($customGroup)) {
99 CRM_Core_Error
::statusBounce(ts('You need more than one custom group to move fields'));
103 '' => ts('- select -'),
115 'name' => ts('Move Custom Field'),
120 'name' => ts('Cancel'),
124 $this->addFormRule(['CRM_Custom_Form_MoveField', 'formRule'], $this);
134 public static function formRule($fields, $files, $self) {
135 $self->_dstGID
= $fields['dst_group_id'];
136 $tmp = CRM_Core_BAO_CustomField
::_moveFieldValidate($self->_srcFID
, $self->_dstGID
);
138 if ($tmp['newGroupID']) {
139 $errors['dst_group_id'] = $tmp['newGroupID'];
141 return empty($errors) ?
TRUE : $errors;
145 * Process the form when submitted.
149 public function postProcess() {
150 CRM_Core_BAO_CustomField
::moveField($this->_srcFID
, $this->_dstGID
);
152 $dstGroup = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup',
156 $srcUrl = CRM_Utils_System
::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_dstGID}");
157 CRM_Core_Session
::setStatus(ts("%1 has been moved to the custom set <a href='%3'>%2</a>.",
159 1 => $this->_srcFieldLabel
,