id = $this->_id; $mapping->find(TRUE); $this->assign('mappingName', $mapping->name); } public function buildQuickForm() { parent::buildQuickForm(); $this->setPageTitle(ts('Field Mapping')); if ($this->_action == CRM_Core_Action::DELETE) { return; } else { $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE ); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( 'CRM_Core_DAO_Mapping', $this->_id, )); $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'description') ); $mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Mapping', 'mapping_type_id')); if ($this->_action == CRM_Core_Action::UPDATE) { $mappingType->freeze(); } } } /** * @return array */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); return $defaults; } /** * Process the form submission. */ public function postProcess() { // store the submitted values in an array $params = $this->exportValues(); if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_id) { CRM_Core_BAO_Mapping::del($this->_id); CRM_Core_Session::setStatus(ts('Selected mapping has been deleted successfully.'), ts('Deleted'), 'success'); } } else { if ($this->_id) { $params['id'] = $this->_id; } CRM_Core_BAO_Mapping::add($params); } } }