* Build the form object.
*/
public function buildQuickForm() {
- $this->setPageTitle($this->_isTagSet ? ts('Tag Set') : ts('Tag'));
-
if ($this->_action == CRM_Core_Action::DELETE) {
if ($this->_id && $tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id')) {
$url = CRM_Utils_System::url('civicrm/tag', "reset=1");
$adminReservedTags = FALSE;
}
$this->assign('adminReservedTags', $adminReservedTags);
-
}
+ $this->setPageTitle($this->_isTagSet ? ts('Tag Set') : ts('Tag'));
parent::buildQuickForm();
}
if (empty($this->_id) || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'color')) {
$defaults['color'] = '#ffffff';
}
+ if (empty($this->_id) && $this->_isTagSet) {
+ $defaults['used_for'] = 'civicrm_contact';
+ }
return $defaults;
}
* Process the form submission.
*/
public function postProcess() {
- $params = $ids = array();
-
// store the submitted values in an array
$params = $this->exportValues();
+ if ($this->_id) {
+ $params['id'] = $this->_id;
+ }
- $ids['tag'] = $this->_id;
if ($this->_action == CRM_Core_Action::ADD ||
$this->_action == CRM_Core_Action::UPDATE
) {
if ($this->_id > 0) {
$tag = civicrm_api3('tag', 'getsingle', array('id' => $this->_id));
CRM_Core_BAO_Tag::del($this->_id);
- CRM_Core_Session::setStatus(ts('The tag \'%1\' has been deleted.', array(1 => $tag['name'])), ts('Deleted'), 'success');
+ CRM_Core_Session::setStatus(ts("The tag '%1' has been deleted.", array(1 => $tag['name'])), ts('Deleted'), 'success');
}
}
else {
- $tag = CRM_Core_BAO_Tag::add($params, $ids);
- CRM_Core_Session::setStatus(ts('The tag \'%1\' has been saved.', array(1 => $tag->name)), ts('Saved'), 'success');
+ $tag = CRM_Core_BAO_Tag::add($params);
+ CRM_Core_Session::setStatus(ts("The tag '%1' has been saved.", array(1 => $tag->name)), ts('Saved'), 'success');
}
}