Merge pull request #22342 from civicrm/5.45
[civicrm-core.git] / CRM / Price / Form / DeleteField.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
19 * This class is to build the form for Deleting Group
20 */
21class CRM_Price_Form_DeleteField extends CRM_Core_Form {
22
23 /**
fe482240 24 * The field id.
6a488035
TO
25 *
26 * @var int
27 */
28 protected $_fid;
29
30 /**
fe482240 31 * The title of the group being deleted.
6a488035
TO
32 *
33 * @var string
34 */
35 protected $_title;
36
37 /**
fe482240 38 * Set up variables to build the form.
6a488035 39 *
6a488035 40 * @return void
b44e3f84 41 * @access protected
95ea96be 42 */
79d7553f 43 public function preProcess() {
6a488035
TO
44 $this->_fid = $this->get('fid');
45
9da8dc8c 46 $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField',
6a488035
TO
47 $this->_fid,
48 'label', 'id'
49 );
50
51 $this->assign('title', $this->_title);
52
203b4734 53 $this->setTitle(ts('Confirm Price Field Delete'));
6a488035
TO
54 }
55
56 /**
fe482240 57 * Build the form object.
6a488035 58 *
6a488035 59 * @return void
6a488035
TO
60 */
61 public function buildQuickForm() {
be2fb01f
CW
62 $this->addButtons([
63 [
c5c263ca
AH
64 'type' => 'next',
65 'name' => ts('Delete Price Field'),
66 'isDefault' => TRUE,
be2fb01f
CW
67 ],
68 [
c5c263ca
AH
69 'type' => 'cancel',
70 'name' => ts('Cancel'),
be2fb01f
CW
71 ],
72 ]);
6a488035
TO
73 }
74
75 /**
fe482240 76 * Process the form when submitted.
6a488035 77 *
6a488035 78 * @return void
6a488035
TO
79 */
80 public function postProcess() {
9da8dc8c 81 if (CRM_Price_BAO_PriceField::deleteField($this->_fid)) {
be2fb01f 82 CRM_Core_Session::setStatus(ts('The Price Field \'%1\' has been deleted.', [1 => $this->_title]), '', 'success');
6a488035
TO
83 }
84 }
96025800 85
6a488035 86}