Sync address custom field file with main file.
authoreileen <emcnaughton@wikimedia.org>
Wed, 21 Mar 2018 04:17:59 +0000 (17:17 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 21 Mar 2018 08:08:55 +0000 (21:08 +1300)
There is no reason for there being 2 files almost the same for custom data

I plan to use this file more broadly (ie. permit custom data on other entities such as email, phone)
and towards that have aligned the 2 files first.

There are minor differences in display
- read only fields show up as frozen for non-address & now for address too (instead of suppressed)
- post help text shows as full text for address currently but after this it shows as a help-icon
which can be clicked on
- display improvements for file custom fields.

Note that I think making address like the main file makes sense as that will be where deliberate
changes have happened.

templates/CRM/Contact/Form/Edit/Address/CustomData.tpl
templates/CRM/Contact/Form/Edit/Address/CustomField.tpl [deleted file]
templates/CRM/Custom/Form/CustomData.tpl
templates/CRM/Custom/Form/CustomField.tpl
templates/CRM/Custom/Form/Edit/CustomField.tpl [new file with mode: 0644]

index 5f2b6a2f3d2f3de54789afba0fc4abad47be110a..1115cfa486fd49d75f3a9302c65a5424bbae16e8 100644 (file)
@@ -36,7 +36,8 @@
             {/if}
             <table class="form-layout-compressed">
                 {foreach from=$cd_edit.fields item=element key=field_id}
-                    {include file="CRM/Contact/Form/Edit/Address/CustomField.tpl"}
+                  {assign var="element_name" value=$element.element_custom_name}
+                  {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.address.$blockId.$element_name}
                 {/foreach}
             </table>
             <div class="spacer"></div>
diff --git a/templates/CRM/Contact/Form/Edit/Address/CustomField.tpl b/templates/CRM/Contact/Form/Edit/Address/CustomField.tpl
deleted file mode 100644 (file)
index 6963a97..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
- +--------------------------------------------------------------------+
- | 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        |
- +--------------------------------------------------------------------+
-*}
-{assign var="element_name" value=$element.element_custom_name}
-
-    {if $element.help_pre}
-        <tr>
-            <td>&nbsp;</td>
-            <td class="html-adjust description">{$element.help_pre}</td>
-        </tr>
-    {/if}
-     {if $element.options_per_line != 0 }
-        <tr>
-            <td class="label">{$form.address.$blockId.$element_name.label}</td>
-            <td class="html-adjust">
-                {assign var="count" value="1"}
-                <table class="form-layout-compressed" style="margin-top: -0.5em;">
-                    <tr>
-                        {* sort by fails for option per line. Added a variable to iterate through the element array*}
-                        {assign var="index" value="1"}
-                        {foreach name=outer key=key item=item from=$form.address.$blockId.$element_name}
-                            {if $index < 10}
-                                {assign var="index" value=`$index+1`}
-                            {else}
-                                <td class="labels font-light">{$form.address.$blockId.$element_name.$key.html}</td>
-                                {if $count == $element.options_per_line}
-                                    </tr>
-                                    <tr>
-                                    {assign var="count" value="1"}
-                                {else}
-                                    {assign var="count" value=`$count+1`}
-                                {/if}
-                            {/if}
-                        {/foreach}
-                    </tr>
-                </table>
-            </td>
-        </tr>
-
-        {if $element.help_post}
-            <tr>
-                <td>&nbsp;</td>
-                <td class="description">{$element.help_post}<br />&nbsp;</td>
-            </tr>
-             {/if}
-    {else}
-        <tr>
-            <td class="label">{$form.address.$blockId.$element_name.label}</td>
-            <td class="html-adjust">
-                {$form.address.$blockId.$element_name.html}&nbsp;
-
-                {if $element.data_type eq 'File'}
-                    {if $element.element_value.data}
-                        <span class="html-adjust"><br />
-                            &nbsp;{ts}Attached File{/ts}: &nbsp;
-                            {if $element.element_value.displayURL }
-                                <a href="{$element.element_value.displayURL}" class='crm-image-popup'>
-                                  <img src="{$element.element_value.displayURL}" height = "100" width="100">
-                                </a>
-                            {else}
-                                <a href="{$element.element_value.fileURL}">{$element.element_value.fileName}</a>
-                            {/if}
-                            {if $element.element_value.deleteURL }
-                                <br />
-                            {$element.element_value.deleteURL}
-                            {/if}
-                        </span>
-                    {/if}
-                {elseif $element.html_type eq 'Autocomplete-Select'}
-        {assign var="element_name" value="address[$blockId][$element_name]" }
-                    {if $element.data_type eq 'ContactReference'}
-                      {include file="CRM/Custom/Form/ContactReference.tpl"}
-                    {/if}
-                {/if}
-            </td>
-        </tr>
-
-        {if $element.help_post}
-
-<td>&nbsp;</td>
-<td class="description">{$element.help_post}<br />&nbsp;</td>
-</tr>
-        {/if}
-{/if}
index d06e35c438eeade225a1567b04b26bfea8ea9eca..4403208135ad972fb7698444131c9249a78f5a2b 100644 (file)
@@ -30,7 +30,8 @@
   {/if}
   <table class="form-layout-compressed">
     {foreach from=$cd_edit.fields item=element key=field_id}
-      {include file="CRM/Custom/Form/CustomField.tpl"}
+      {assign var="element_name" value=$element.element_name}
+      {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name}
     {/foreach}
   </table>
   <div class="spacer"></div>
@@ -54,7 +55,8 @@
         {/if}
         <table>
           {foreach from=$cd_edit.fields item=element key=field_id}
-            {include file="CRM/Custom/Form/CustomField.tpl"}
+            {assign var="element_name" value=$element.element_name}
+            {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name}
           {/foreach}
         </table>
         <div class="spacer"></div>
@@ -82,7 +84,8 @@
         {/if}
         <table class="form-layout-compressed">
           {foreach from=$cd_edit.fields item=element key=field_id}
-            {include file="CRM/Custom/Form/CustomField.tpl"}
+            {assign var="element_name" value=$element.element_name}
+            {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name}
           {/foreach}
         </table>
         <div class="spacer"></div>
index 7dc3cd29381c8117d478390305fb96fe54126390..0ef7da5dd70a555a54119ce05c1701c32e4df66a 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{assign var="element_name" value=$element.element_name}
-
-    {if $element.help_pre}
-        <tr class="custom_field-help-pre-row {$element.element_name}-row-help-pre">
-            <td>&nbsp;</td>
-            <td class="html-adjust description">{$element.help_pre}</td>
-        </tr>
-    {/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.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
-            <td class="html-adjust">
-                {assign var="count" value="1"}
-                <table class="form-layout-compressed" style="margin-top: -0.5em;">
-                    <tr>
-                        {* sort by fails for option per line. Added a variable to iterate through the element array*}
-                        {assign var="index" value="1"}
-                        {foreach name=outer key=key item=item from=$form.$element_name}
-                            {if $index < 10}
-                                {assign var="index" value=`$index+1`}
-                            {else}
-                                <td class="labels font-light">{$form.$element_name.$key.html}</td>
-                                {if $count == $element.options_per_line}
-                                    </tr>
-                                    <tr>
-                                    {assign var="count" value="1"}
-                                {else}
-                                    {assign var="count" value=`$count+1`}
-                                {/if}
-                            {/if}
-                        {/foreach}
-                    </tr>
-                </table>
-            </td>
-        </tr>
+{* this file is deprecated & it's recommended to define formElement in the calling function. As of 5.1
+ it is no longer used by core & is only retained in case it is used by extensions *}
 
-    {else}
-        <tr class="custom_field-row {$element.element_name}-row">
-            <td class="label">{$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
-            <td class="html-adjust">
-                {$form.$element_name.html}&nbsp;
-                {if $element.data_type eq 'File'}
-                    {if $element.element_value.data}
-                      <div class="crm-attachment-wrapper crm-entity" id="file_{$element_name}">
-                        <span class="html-adjust"><br />
-                            &nbsp;{ts}Attached File{/ts}: &nbsp;
-                            {if $element.element_value.displayURL}
-                                <a href="{$element.element_value.displayURL}" class='crm-image-popup crm-attachment'>
-                                  <img src="{$element.element_value.displayURL}"
-                                       height = "{$element.element_value.imageThumbHeight}"
-                                       width="{$element.element_value.imageThumbWidth}">
-                                </a>
-                            {else}
-                                <a class="crm-attachment" href="{$element.element_value.fileURL}">{$element.element_value.fileName}</a>
-                            {/if}
-                            {if $element.element_value.deleteURL}
-                                   <a href="#" class="crm-hover-button delete-attachment" data-filename="{$element.element_value.fileName}" data-args="{$element.element_value.deleteURLArgs}" title="{ts}Delete File{/ts}"><span class="icon delete-icon"></span></a>
-                            {/if}
-                        </span>
-                      </div>
-                    {/if}
-                {elseif $element.html_type eq 'Autocomplete-Select'}
-                  {if $element.data_type eq 'ContactReference'}
-                    {include file="CRM/Custom/Form/ContactReference.tpl"}
-                  {/if}
-                {/if}
-            </td>
-        </tr>
-
-    {/if}
+{assign var="element_name" value=$element.element_name}
+{include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name}
diff --git a/templates/CRM/Custom/Form/Edit/CustomField.tpl b/templates/CRM/Custom/Form/Edit/CustomField.tpl
new file mode 100644 (file)
index 0000000..9b345a1
--- /dev/null
@@ -0,0 +1,99 @@
+{*
++--------------------------------------------------------------------+
+| CiviCRM version 4.7                                                |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2018                                |
++--------------------------------------------------------------------+
+| 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        |
++--------------------------------------------------------------------+
+*}
+
+{if $element.help_pre}
+  <tr class="custom_field-help-pre-row {$element.element_name}-row-help-pre">
+    <td>&nbsp;</td>
+    <td class="html-adjust description">{$element.help_pre}</td>
+  </tr>
+{/if}
+{if $element.options_per_line != 0 }
+  <tr class="custom_field-row {$element.element_name}-row">
+    <td
+      class="label">{$formElement.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
+    <td class="html-adjust">
+      {assign var="count" value="1"}
+      <table class="form-layout-compressed" style="margin-top: -0.5em;">
+        <tr>
+          {* sort by fails for option per line. Added a variable to iterate through the element array*}
+          {assign var="index" value="1"}
+          {foreach name=outer key=key item=item from=$formElement}
+          {if $index < 10}
+          {assign var="index" value=`$index+1`}
+          {else}
+          <td class="labels font-light">{$formElement.$key.html}</td>
+          {if $count == $element.options_per_line}
+        </tr>
+        <tr>
+          {assign var="count" value="1"}
+          {else}
+          {assign var="count" value=`$count+1`}
+          {/if}
+          {/if}
+          {/foreach}
+        </tr>
+      </table>
+    </td>
+  </tr>
+{else}
+  <tr class="custom_field-row {$element.element_name}-row">
+    <td class="label">{$formElement.label}
+      {if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}
+    </td>
+    <td class="html-adjust">
+      {$formElement.html}&nbsp;
+      {if $element.data_type eq 'File'}
+        {if $element.element_value.data}
+          <div class="crm-attachment-wrapper crm-entity" id="file_{$element.element_name}">
+            <span class="html-adjust"><br/>&nbsp;{ts}Attached File{/ts}: &nbsp;
+              {if $element.element_value.displayURL}
+                <a href="{$element.element_value.displayURL}" class='crm-image-popup crm-attachment'>
+                  <img src="{$element.element_value.displayURL}"
+                       height="{$element.element_value.imageThumbHeight}"
+                       width="{$element.element_value.imageThumbWidth}">
+                </a>
+              {else}
+                <a class="crm-attachment" href="{$element.element_value.fileURL}">{$element.element_value.fileName}</a>
+              {/if}
+              {if $element.element_value.deleteURL}
+                <a href="#" class="crm-hover-button delete-attachment"
+                   data-filename="{$element.element_value.fileName}"
+                   data-args="{$element.element_value.deleteURLArgs}" title="{ts}Delete File{/ts}">
+                  <span class="icon delete-icon"></span>
+                </a>
+              {/if}
+            </span>
+          </div>
+        {/if}
+      {elseif $element.html_type eq 'Autocomplete-Select'}
+        {if $element.data_type eq 'ContactReference'}
+          {assign var="element_name" value=$element.element_name}
+          {include file="CRM/Custom/Form/ContactReference.tpl"}
+        {/if}
+      {/if}
+    </td>
+  </tr>
+{/if}