/** * Method to add form elements * * @access protected */ protected function addFormElements() { $roleList = CRM_Contactsegment_Utils::getRoleList(); $parentList = CRM_Contactsegment_Utils::getParentList(); if ($this->_parentSegmentId) { $childList = array("- select -") + CRM_Contactsegment_Utils::getChildList($this->_parentSegmentId); } else { if (isset($this->_contactSegment['segment_id'])) { $childList = array("- select -") + CRM_Contactsegment_Utils::getChildList($this->_contactSegment['segment_id']); } else { $defaultParentId = CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_segment where parent_id IS NULL ORDER BY label ASC LIMIT 1'); $childList = array("- select -") + CRM_Contactsegment_Utils::getChildList($defaultParentId); } } $this->add('hidden', 'contact_id'); $this->add('hidden', 'contact_segment_id'); $this->add('select', 'contact_segment_role', ts('Role'), $roleList, true); $this->add('select', 'segment_parent', ts($this->_parentLabel), $parentList, true); $this->add('select', 'segment_child', ts($this->_childLabel), $childList); $this->addDate('start_date', ts('Start Date'), true); $this->addDate('end_date', ts('End Date'), false); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to add form elements * * @access protected */ protected function addFormElements() { $roleList = CRM_Contactsegment_Utils::getRoleList(); $this->add('text', 'parent_label', ts('Label'), array('size' => 80), true); $this->add('text', 'child_label', ts('Label'), array('size' => 80), true); $parentRoleSelect = $this->addElement('advmultiselect', 'parent_roles', ts('Roles'), $roleList, array('size' => 5, 'style' => 'width:280px', 'class' => 'advmultselect'), TRUE); $parentRoleSelect->setButtonAttributes('add', array('value' => ts('Use for parent') . " >>")); $parentRoleSelect->setButtonAttributes('remove', array('value' => "<< " . ts('Not used for parent'))); $childRoleSelect = $this->addElement('advmultiselect', 'child_roles', ts('Roles'), $roleList, array('size' => 5, 'style' => 'width:280px', 'class' => 'advmultselect'), TRUE); $childRoleSelect->setButtonAttributes('add', array('value' => ts('Use for child') . " >>")); $childRoleSelect->setButtonAttributes('remove', array('value' => "<< " . ts('Not used for child'))); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }