static function add(&$params) {
$caseTypeDAO = new CRM_Case_DAO_CaseType();
+ // form the name only if missing: CRM-627
+ $nameParam = CRM_Utils_Array::value('name', $params, NULL);
+ if (!$nameParam && empty($params['id'])) {
+ $params['name'] = CRM_Utils_String::titleToVar($params['title']);
+ }
+
// function to format definition column
self::convertDefinitionToXML($params);
* @access public
*/
function civicrm_api3_case_type_create($params) {
- civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name'));
+ civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__));
if (!array_key_exists('is_active', $params) && empty($params['id'])) {
$params['is_active'] = TRUE;
return crmApi('CaseType', 'getsingle', {id: $route.current.params.id});
}
else {
- return { title: "New case type", name: "New case type", is_active: "1",
+ return { title: "New case type", name: "New case type", is_active: "1", weight: "1",
definition: _.extend({}, newCaseTypeDefinitionTemplate) };
}
}
};
$scope.save = function() {
- crmApi('CaseType', 'create', $scope.caseType, true);
+ var result = crmApi('CaseType', 'create', $scope.caseType, true);
+ result.success(function(data) {
+ if (data.is_error == 0) {
+ $scope.caseType.id = data.id;
+ }
+ });
};
$scope.$watchCollection('caseType.definition.activitySets', function() {