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 generates form components for Mapping.
21 class CRM_Admin_Form_Mapping
extends CRM_Admin_Form
{
26 public $submitOnce = TRUE;
29 * Build the form object.
31 public function preProcess() {
33 $mapping = new CRM_Core_DAO_Mapping();
34 $mapping->id
= $this->_id
;
36 $this->assign('mappingName', $mapping->name
);
39 public function buildQuickForm() {
40 parent
::buildQuickForm();
41 $this->setPageTitle(ts('Field Mapping'));
43 if ($this->_action
== CRM_Core_Action
::DELETE
) {
47 $this->applyFilter('__ALL__', 'trim');
49 $this->add('text', 'name', ts('Name'),
50 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE
52 $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [
53 'CRM_Core_DAO_Mapping',
57 $this->addElement('text', 'description', ts('Description'),
58 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_Mapping', 'description')
61 $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Mapping', 'mapping_type_id'));
63 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
64 $mappingType->freeze();
72 public function setDefaultValues() {
73 $defaults = parent
::setDefaultValues();
78 * Process the form submission.
80 public function postProcess() {
81 // store the submitted values in an array
82 $params = $this->exportValues();
84 if ($this->_action
== CRM_Core_Action
::DELETE
) {
86 CRM_Core_BAO_Mapping
::del($this->_id
);
87 CRM_Core_Session
::setStatus(ts('Selected mapping has been deleted successfully.'), ts('Deleted'), 'success');
92 $params['id'] = $this->_id
;
95 CRM_Core_BAO_Mapping
::add($params);