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
19 * This class is to build the form for Deleting Group
21 class CRM_Custom_Form_MoveField
extends CRM_Core_Form
{
52 * The title of the field being moved.
56 protected $_srcFieldLabel;
59 * Set up variables to build the form.
64 public function preProcess() {
65 $this->_srcFID
= CRM_Utils_Request
::retrieve('fid', 'Positive',
69 $this->_srcGID
= CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomField',
74 $this->_srcFieldLabel
= CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomField',
79 $this->setTitle(ts('Custom Field Move: %1',
80 [1 => $this->_srcFieldLabel
]
83 $session = CRM_Core_Session
::singleton();
84 $session->pushUserContext(CRM_Utils_System
::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_srcGID}"));
88 * Build the form object.
92 public function buildQuickForm() {
94 $customGroup = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_CustomField', 'custom_group_id');
95 unset($customGroup[$this->_srcGID
]);
96 if (empty($customGroup)) {
97 CRM_Core_Error
::statusBounce(ts('You need more than one custom group to move fields'));
101 '' => ts('- select -'),
113 'name' => ts('Move Custom Field'),
118 'name' => ts('Cancel'),
122 $this->addFormRule(['CRM_Custom_Form_MoveField', 'formRule'], $this);
132 public static function formRule($fields, $files, $self) {
133 $self->_dstGID
= $fields['dst_group_id'];
134 $tmp = CRM_Core_BAO_CustomField
::_moveFieldValidate($self->_srcFID
, $self->_dstGID
);
136 if ($tmp['newGroupID']) {
137 $errors['dst_group_id'] = $tmp['newGroupID'];
139 return empty($errors) ?
TRUE : $errors;
143 * Process the form when submitted.
147 public function postProcess() {
148 CRM_Core_BAO_CustomField
::moveField($this->_srcFID
, $this->_dstGID
);
150 $dstGroup = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup',
154 $srcUrl = CRM_Utils_System
::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_dstGID}");
155 CRM_Core_Session
::setStatus(ts("%1 has been moved to the custom set <a href='%3'>%2</a>.",
157 1 => $this->_srcFieldLabel
,