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
{
24 * Build the form object.
26 public function preProcess() {
28 $mapping = new CRM_Core_DAO_Mapping();
29 $mapping->id
= $this->_id
;
31 $this->assign('mappingName', $mapping->name
);
34 public function buildQuickForm() {
35 parent
::buildQuickForm();
36 $this->setPageTitle(ts('Field Mapping'));
38 if ($this->_action
== CRM_Core_Action
::DELETE
) {
42 $this->applyFilter('__ALL__', 'trim');
44 $this->add('text', 'name', ts('Name'),
45 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE
47 $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [
48 'CRM_Core_DAO_Mapping',
52 $this->addElement('text', 'description', ts('Description'),
53 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_Mapping', 'description')
56 $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant
::get('CRM_Core_DAO_Mapping', 'mapping_type_id'));
58 if ($this->_action
== CRM_Core_Action
::UPDATE
) {
59 $mappingType->freeze();
67 public function setDefaultValues() {
68 $defaults = parent
::setDefaultValues();
73 * Process the form submission.
75 public function postProcess() {
76 // store the submitted values in an array
77 $params = $this->exportValues();
79 if ($this->_action
== CRM_Core_Action
::DELETE
) {
81 CRM_Core_BAO_Mapping
::del($this->_id
);
82 CRM_Core_Session
::setStatus(ts('Selected mapping has been deleted successfully.'), ts('Deleted'), 'success');
87 $params['id'] = $this->_id
;
90 CRM_Core_BAO_Mapping
::add($params);