From 7ef0d72c6534df9e171f3258af460b8f441ad849 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 29 Dec 2015 22:27:16 -0500 Subject: [PATCH] Improve open case form --- CRM/Case/Form/Activity/OpenCase.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Case/Form/Activity/OpenCase.php b/CRM/Case/Form/Activity/OpenCase.php index 1960c212b9..2bb75669ed 100644 --- a/CRM/Case/Form/Activity/OpenCase.php +++ b/CRM/Case/Form/Activity/OpenCase.php @@ -114,8 +114,16 @@ class CRM_Case_Form_Activity_OpenCase { // set default case type passed in url if ($form->_caseTypeId) { - $caseType = $form->_caseTypeId; - $defaults['case_type_id'] = $caseType; + $defaults['case_type_id'] = $form->_caseTypeId; + } + else { + // TODO: Not possible yet to set a default case type in the system + // For now just add the convenience of auto-selecting if there is only one option + $caseTypes = CRM_Case_BAO_Case::buildOptions('case_type_id', 'create'); + if (count($caseTypes) == 1) { + reset($caseTypes); + $defaults['case_type_id'] = key($caseTypes); + } } $medium = CRM_Core_OptionGroup::values('encounter_medium', FALSE, FALSE, FALSE, 'AND is_default = 1'); -- 2.25.1