Add dynamic loading of help text for custom fields CRM-12038
authorColeman Watts <coleman@civicrm.org>
Thu, 7 Mar 2013 00:50:24 +0000 (16:50 -0800)
committerColeman Watts <coleman@civicrm.org>
Thu, 7 Mar 2013 00:50:24 +0000 (16:50 -0800)
CRM/Core/Smarty/plugins/function.help.php
templates/CRM/Custom/Form/CustomField.hlp [new file with mode: 0644]
templates/CRM/Custom/Form/CustomField.tpl
templates/CRM/Custom/Form/Preview.tpl

index 30070a6a227ae08eecd76b115e589205887c6163..d1c12cbb78fe792f4778f334cfc5fecdd6ec1575 100644 (file)
@@ -47,13 +47,6 @@ function smarty_function_help($params, &$smarty) {
     return;
   }
 
-  // Legacy support for old-style $params['text']
-  // TODO: This is probably no longer used, so remove
-  $help = '';
-  if (isset($params['text'])) {
-    $help = '<div class="crm-help">' . $params['text'] . '</div>';
-  }
-
   if (empty($params['file']) && isset($smarty->_tpl_vars['tplFile'])) {
     $params['file'] = $smarty->_tpl_vars['tplFile'];
   }
diff --git a/templates/CRM/Custom/Form/CustomField.hlp b/templates/CRM/Custom/Form/CustomField.hlp
new file mode 100644 (file)
index 0000000..c6be39d
--- /dev/null
@@ -0,0 +1,30 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.3                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2010                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+{* Dynamically fetch the help text for a custom field *}
+{htxt id=$id}
+  {crmAPI var='result' entity='CustomField' action='getsingle' sequential=1 id=$id}
+  {$result.help_post}
+{/htxt}
index e24b785829878c1f680fc17dbff45f9426ca845d..e77c40e92441e5d1e219ac470ec259be6930c0c2 100644 (file)
@@ -24,9 +24,6 @@
  +--------------------------------------------------------------------+
 *}
 {assign var="element_name" value=$element.element_name}
-{if $element.help_post}
-    {assign var="help_post" value=$element.help_post}
-{/if}
 
     {if $element.help_pre}
         <tr class="custom_field-help-pre-row {$element.element_name}-row-help-pre">
@@ -36,7 +33,7 @@
     {/if}
      {if $element.options_per_line != 0 }
         <tr class="custom_field-row {$element.element_name}-row">
-            <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$help_post}{/if}</td>
+            <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if}</td>
             <td class="html-adjust">
                 {assign var="count" value="1"}
                 <table class="form-layout-compressed" style="margin-top: -0.5em;">
@@ -67,7 +64,7 @@
 
     {else}
         <tr class="custom_field-row {$element.element_name}-row">
-            <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$help_post}{/if}</td>
+            <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if}</td>
             <td class="html-adjust">
                 {if $element.data_type neq 'Date' OR ($element.data_type eq 'Date' AND $element.is_view eq 1)}
                     {$form.$element_name.html}&nbsp;
index 4b2840d883f2c9aadb2dfef277234f7cb13cae96..5e01810f96e24560c762250cfd54732ca8c8846d 100644 (file)
@@ -53,7 +53,7 @@
         {*assign var="element_name" value=$element.custom_group_id|cat:_|cat:$field_id|cat:_|cat:$element.name*}
         {assign var="element_name" value=$element.element_name}
         <tr>
-         <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$element.help_post}{/if}</td>
+         <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if}</td>
          <td>
             {assign var="count" value="1"}
                 <table class="form-layout-compressed">
@@ -86,7 +86,7 @@
         {*assign var="element_name" value=$group_id|cat:_|cat:$field_id|cat:_|cat:$element.name*}
         {assign var="element_name" value=$element.element_name}
         <tr>
-          <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element_name text=$element.help_post}{/if}</td>
+          <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$form.$element_name.label}{/if}</td>
         <td>
       {if $element.data_type neq 'Date'}
             {$form.$element_name.html}&nbsp;