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 a field
21 class CRM_Custom_Form_DeleteField
extends CRM_Core_Form
{
31 * The title of the group being deleted.
38 * Set up variables to build the form.
43 public function preProcess() {
44 $this->_id
= $this->get('id');
47 $params = ['id' => $this->_id
];
48 CRM_Core_BAO_CustomField
::retrieve($params, $defaults);
50 $this->_title
= $defaults['label'] ??
NULL;
51 $this->assign('title', $this->_title
);
52 $this->setTitle(ts('Delete %1', [1 => $this->_title
]));
56 * Build the form object.
60 public function buildQuickForm() {
65 'name' => ts('Delete Custom Field'),
70 'name' => ts('Cancel'),
76 * Process the form when submitted.
80 public function postProcess() {
81 $field = new CRM_Core_DAO_CustomField();
82 $field->id
= $this->_id
;
85 CRM_Core_BAO_CustomField
::deleteField($field);
87 // also delete any profiles associted with this custom field
88 CRM_Core_Session
::setStatus(ts('The custom field \'%1\' has been deleted.', [1 => $field->label
]), '', 'success');