_id = $this->get('id'); $this->_BAOName = $this->get('BAOName'); $this->_values = array(); if (isset($this->_id)) { $params = array('id' => $this->_id); // this is needed if the form is outside the CRM name space $baoName = $this->_BAOName; $baoName::retrieve($params, $this->_values ); } } /** * This function sets the default values for the form. Note that in edit/view mode * the default values are retrieved from the database * * @access public * * @return array */ function setDefaultValues() { if (isset($this->_id) && empty($this->_values)) { $this->_values = array(); $params = array('id' => $this->_id); $baoName = $this->_BAOName; $baoName::retrieve($params, $this->_values ); } $defaults = $this->_values; if ($this->_action == CRM_Core_Action::DELETE && isset($defaults['name']) ) { $this->assign('delName', $defaults['name']); } // its ok if there is no element called is_active $defaults['is_active'] = ($this->_id) ? CRM_Utils_Array::value('is_active', $defaults) : 1; if (!empty($defaults['parent_id'])) { $this->assign('is_parent', TRUE); } return $defaults; } /** * Add standard buttons * * @return void * @access public */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) { $this->addButtons(array( array( 'type' => 'cancel', 'name' => ts('Done'), 'isDefault' => TRUE, ), ) ); } else { $this->addButtons(array( array( 'type' => 'next', 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'), 'isDefault' => TRUE, ), array( 'type' => 'cancel', 'name' => ts('Cancel'), ), ) ); } } }