From 4247b886dcd91701c2dd01a88137f4e4e82d22a5 Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 23 May 2017 16:01:53 +0530 Subject: [PATCH 1/3] CRM-20624 - Expose description field for option values in UI --- CRM/Core/BAO/CustomOption.php | 4 ++-- CRM/Custom/Form/Option.php | 2 ++ CRM/Custom/Page/AJAX.php | 1 + templates/CRM/Custom/Form/Option.tpl | 3 +++ templates/CRM/Custom/Page/Option.tpl | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index efbb6518c4e6..e19e169ed15d 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -159,7 +159,7 @@ static public function getOptionListSelector(&$params) { $options[$dao->id]['is_default'] = ''; } } - + $options[$dao->id]['description'] = $dao->description; $options[$dao->id]['class'] = $dao->id . ',' . $class; $options[$dao->id]['is_active'] = empty($dao->is_active) ? ts('No') : ts('Yes'); $options[$dao->id]['links'] = CRM_Core_Action::formLink($links, @@ -176,7 +176,7 @@ static public function getOptionListSelector(&$params) { $dao->id ); } - + // crm_core_Error::Debug('t', $options); return $options; } diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index 00b450774431..c2abadca564a 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -181,6 +181,7 @@ public function buildQuickForm() { $this->add('text', 'value', ts('Option Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), TRUE); + $this->add('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description')); // weight $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE); $this->addRule('weight', ts('is a numeric field'), 'numeric'); @@ -406,6 +407,7 @@ public function postProcess() { $customOption->label = $params['label']; $customOption->name = CRM_Utils_String::titleToVar($params['label']); $customOption->weight = $params['weight']; + $customOption->description = $params['description']; $customOption->value = $params['value']; $customOption->is_active = CRM_Utils_Array::value('is_active', $params, FALSE); diff --git a/CRM/Custom/Page/AJAX.php b/CRM/Custom/Page/AJAX.php index ef99f073b5be..62c95c715700 100644 --- a/CRM/Custom/Page/AJAX.php +++ b/CRM/Custom/Page/AJAX.php @@ -57,6 +57,7 @@ public static function getOptionList() { $selectorElements = array( 'label', 'value', + 'description', 'is_default', 'is_active', 'links', diff --git a/templates/CRM/Custom/Form/Option.tpl b/templates/CRM/Custom/Form/Option.tpl index ac2a45ac2273..f4357b9cc1fd 100644 --- a/templates/CRM/Custom/Form/Option.tpl +++ b/templates/CRM/Custom/Form/Option.tpl @@ -42,6 +42,9 @@ {$form.value.label} {$form.value.html} + + {$form.description.label} + {$form.description.html} {$form.weight.label} {$form.weight.html} diff --git a/templates/CRM/Custom/Page/Option.tpl b/templates/CRM/Custom/Page/Option.tpl index 7cd373f67dc0..8d1294e16703 100644 --- a/templates/CRM/Custom/Page/Option.tpl +++ b/templates/CRM/Custom/Page/Option.tpl @@ -42,6 +42,7 @@ {ts}Label{/ts} {ts}Value{/ts} + {ts}Description{/ts} {ts}Default{/ts} {ts}Enabled?{/ts}   @@ -70,6 +71,7 @@ {sClass:'crm-custom_option-label'}, {sClass:'crm-custom_option-value'}, {sClass:'crm-custom_option-default_value'}, + {sClass:'crm-custom_option-default_description'}, {sClass:'crm-custom_option-is_active'}, {sClass:'crm-custom_option-links'}, {sClass:'hiddenElement'} From 89a028fe19e0f3d62b489e9a3089c4d9583688aa Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 23 May 2017 16:48:56 +0530 Subject: [PATCH 2/3] CRM-20624 - Expose description field for option values in UI --- CRM/Core/BAO/CustomOption.php | 2 +- templates/CRM/Custom/Page/Option.tpl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index e19e169ed15d..a1c0dfe276be 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -176,7 +176,7 @@ static public function getOptionListSelector(&$params) { $dao->id ); } - // crm_core_Error::Debug('t', $options); + return $options; } diff --git a/templates/CRM/Custom/Page/Option.tpl b/templates/CRM/Custom/Page/Option.tpl index 8d1294e16703..b631fe63190a 100644 --- a/templates/CRM/Custom/Page/Option.tpl +++ b/templates/CRM/Custom/Page/Option.tpl @@ -42,7 +42,7 @@ {ts}Label{/ts} {ts}Value{/ts} - {ts}Description{/ts} + {ts}Description{/ts} {ts}Default{/ts} {ts}Enabled?{/ts}   @@ -71,7 +71,7 @@ {sClass:'crm-custom_option-label'}, {sClass:'crm-custom_option-value'}, {sClass:'crm-custom_option-default_value'}, - {sClass:'crm-custom_option-default_description'}, + {sClass:'crm-custom_option-description'}, {sClass:'crm-custom_option-is_active'}, {sClass:'crm-custom_option-links'}, {sClass:'hiddenElement'} From a51902bcb6cf76f2cc559b96cb98897bf391f1ad Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 23 May 2017 17:25:37 +0530 Subject: [PATCH 3/3] minor fix --- templates/CRM/Custom/Page/Option.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/CRM/Custom/Page/Option.tpl b/templates/CRM/Custom/Page/Option.tpl index b631fe63190a..3fb672694193 100644 --- a/templates/CRM/Custom/Page/Option.tpl +++ b/templates/CRM/Custom/Page/Option.tpl @@ -71,7 +71,7 @@ {sClass:'crm-custom_option-label'}, {sClass:'crm-custom_option-value'}, {sClass:'crm-custom_option-default_value'}, - {sClass:'crm-custom_option-description'}, + {sClass:'crm-custom_option-default_description'}, {sClass:'crm-custom_option-is_active'}, {sClass:'crm-custom_option-links'}, {sClass:'hiddenElement'}