Skip to content

Commit

Permalink
Start to sync address custom field file with main file.
Browse files Browse the repository at this point in the history
The goal here is to have one generic file ie. Edit/Address/CustomField.tpl
will cease to exist. I plan to use this file more broadly (ie. permit custom data on other entities such as email, phone)
  • Loading branch information
eileenmcnaughton committed Mar 21, 2018
1 parent 6bfb9c9 commit 2d44eb4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
7 changes: 6 additions & 1 deletion templates/CRM/Contact/Form/Edit/Address/CustomData.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
{/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/Contact/Form/Edit/Address/CustomField.tpl"
formElement = $form.address.$blockId.$element_name
element_name = $element_name
}
{/foreach}
</table>
<div class="spacer"></div>
Expand Down
12 changes: 5 additions & 7 deletions templates/CRM/Contact/Form/Edit/Address/CustomField.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
| 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>
Expand All @@ -33,18 +31,18 @@
{/if}
{if $element.options_per_line != 0 }
<tr>
<td class="label">{$form.address.$blockId.$element_name.label}</td>
<td class="label">{$formElement.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}
{foreach name=outer key=key item=item from=$formElement}
{if $index < 10}
{assign var="index" value=`$index+1`}
{else}
<td class="labels font-light">{$form.address.$blockId.$element_name.$key.html}</td>
<td class="labels font-light">{$formElement.$key.html}</td>
{if $count == $element.options_per_line}
</tr>
<tr>
Expand All @@ -67,9 +65,9 @@
{/if}
{else}
<tr>
<td class="label">{$form.address.$blockId.$element_name.label}</td>
<td class="label">{$formElement.label}</td>
<td class="html-adjust">
{$form.address.$blockId.$element_name.html}&nbsp;
{$formElement.html}&nbsp;

{if $element.data_type eq 'File'}
{if $element.element_value.data}
Expand Down
11 changes: 8 additions & 3 deletions templates/CRM/Custom/Form/CustomData.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
{/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/CustomField.tpl"
element_name=$element.element_name
formElement=$form.$element_name
}
{/foreach}
</table>
<div class="spacer"></div>
Expand All @@ -54,7 +59,7 @@
{/if}
<table>
{foreach from=$cd_edit.fields item=element key=field_id}
{include file="CRM/Custom/Form/CustomField.tpl"}
{include file="CRM/Custom/Form/CustomField.tpl element_name=$element.element_name"}
{/foreach}
</table>
<div class="spacer"></div>
Expand Down Expand Up @@ -82,7 +87,7 @@
{/if}
<table class="form-layout-compressed">
{foreach from=$cd_edit.fields item=element key=field_id}
{include file="CRM/Custom/Form/CustomField.tpl"}
{include file="CRM/Custom/Form/CustomField.tpl" element_name=$element.element_name}
{/foreach}
</table>
<div class="spacer"></div>
Expand Down
11 changes: 5 additions & 6 deletions templates/CRM/Custom/Form/CustomField.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
| 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">
Expand All @@ -33,18 +32,18 @@
{/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="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=$form.$element_name}
{foreach name=outer key=key item=item from=$formElement}
{if $index < 10}
{assign var="index" value=`$index+1`}
{else}
<td class="labels font-light">{$form.$element_name.$key.html}</td>
<td class="labels font-light">{$formElement.$key.html}</td>
{if $count == $element.options_per_line}
</tr>
<tr>
Expand All @@ -61,9 +60,9 @@

{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="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">
{$form.$element_name.html}&nbsp;
{$formElement.html}&nbsp;
{if $element.data_type eq 'File'}
{if $element.element_value.data}
<div class="crm-attachment-wrapper crm-entity" id="file_{$element_name}">
Expand Down

0 comments on commit 2d44eb4

Please sign in to comment.