diff --git a/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl b/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl index 1115cfa486fd..feaa7c09882c 100644 --- a/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl +++ b/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl @@ -31,17 +31,7 @@ {$cd_edit.title}
- {if $cd_edit.help_pre} -
{$cd_edit.help_pre}
- {/if} - - {foreach from=$cd_edit.fields item=element key=field_id} - {assign var="element_name" value=$element.element_custom_name} - {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.address.$blockId.$element_name} - {/foreach} -
-
- {if $cd_edit.help_post}
{$cd_edit.help_post}
{/if} + {include file="CRM/Custom/Form/Edit/CustomData.tpl" customDataEntity='address'}
diff --git a/templates/CRM/Contact/Form/Edit/CustomData.tpl b/templates/CRM/Contact/Form/Edit/CustomData.tpl index 73d994396bdc..8b5606a8ab33 100644 --- a/templates/CRM/Contact/Form/Edit/CustomData.tpl +++ b/templates/CRM/Contact/Form/Edit/CustomData.tpl @@ -38,21 +38,7 @@
{$cd_edit.title}
-
- {if $cd_edit.is_multiple eq 1} - {if $cd_edit.table_id} - - - - {ts}Delete{/ts} - - - -
- {/if} - {/if} {include file="CRM/Custom/Form/CustomData.tpl" formEdit=true}
diff --git a/templates/CRM/Custom/Form/CustomData.tpl b/templates/CRM/Custom/Form/CustomData.tpl index 4403208135ad..c0de8e0b75da 100644 --- a/templates/CRM/Custom/Form/CustomData.tpl +++ b/templates/CRM/Custom/Form/CustomData.tpl @@ -25,44 +25,18 @@ *} {* Custom Data form*} {if $formEdit} - {if $cd_edit.help_pre} -
{$cd_edit.help_pre}
- {/if} - - {foreach from=$cd_edit.fields item=element key=field_id} - {assign var="element_name" value=$element.element_name} - {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} - {/foreach} -
-
- {if $cd_edit.help_post} -
{$cd_edit.help_post}
- {/if} - {if $cd_edit.is_multiple and ( ( $cd_edit.max_multiple eq '' ) or ( $cd_edit.max_multiple > 0 and $cd_edit.max_multiple > $cgCount ) ) } - - {/if} + {include file="CRM/Custom/Form/Edit/CustomData.tpl" customDataEntity=''} {else} {foreach from=$groupTree item=cd_edit key=group_id name=custom_sets} {if $cd_edit.is_multiple and $multiRecordDisplay eq 'single'} + {assign var="isSingleRecordEdit" value=TRUE} + {else} + {* always assign to prevent leakage*} + {assign var="isSingleRecordEdit" value=''} + {/if} + {if $isSingleRecordEdit}
- {if $cd_edit.help_pre} -
{$cd_edit.help_pre}
- {/if} - - {foreach from=$cd_edit.fields item=element key=field_id} - {assign var="element_name" value=$element.element_name} - {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} - {/foreach} -
-
- {if $cd_edit.help_post} -
{$cd_edit.help_post}
- {/if} + {include file="CRM/Custom/Form/Edit/CustomData.tpl" customDataEntity=''}
{else}
@@ -72,43 +46,9 @@
{/if}
- {if $cd_edit.is_multiple eq 1 and $cd_edit.table_id and $contactId and !$skipTitle and $cd_edit.style eq 'Inline'} - {assign var=tableID value=$cd_edit.table_id} - - {ts}Delete{/ts} - - {/if} - {if $cd_edit.help_pre} -
{$cd_edit.help_pre}
- {/if} - - {foreach from=$cd_edit.fields item=element key=field_id} - {assign var="element_name" value=$element.element_name} - {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} - {/foreach} -
-
- {if $cd_edit.help_post} -
{$cd_edit.help_post}
- {/if} + {include file="CRM/Custom/Form/Edit/CustomData.tpl" customDataEntity=''}
- {if $cd_edit.is_multiple and ( ( $cd_edit.max_multiple eq '' ) or ( $cd_edit.max_multiple > 0 and $cd_edit.max_multiple > $cgCount ) ) } - {if $skipTitle} - {* We don't yet support adding new records in inline-edit forms *} -
- {ts 1=$cd_edit.title}Click "Edit Contact" to add more %1 records{/ts} -
- {else} - - {/if} - {/if} {/if}
{/foreach} diff --git a/templates/CRM/Custom/Form/Edit/CustomData.tpl b/templates/CRM/Custom/Form/Edit/CustomData.tpl new file mode 100644 index 000000000000..4af50207837c --- /dev/null +++ b/templates/CRM/Custom/Form/Edit/CustomData.tpl @@ -0,0 +1,45 @@ +{if !$isSingleRecordEdit && $cd_edit.is_multiple eq 1 and $cd_edit.table_id and $contactId and !$skipTitle and $cd_edit.style eq 'Inline'} + {assign var=tableID value=$cd_edit.table_id} + + {ts}Delete{/ts} + +{/if} + +{if $cd_edit.help_pre} +
{$cd_edit.help_pre}
+{/if} + + {foreach from=$cd_edit.fields item=element key=field_id} + {if $customDataEntity && $blockId} + {* custom data entity combined with blockId tells us we have an entity with mutliple blocks + such as address. Some risk of leakage on blockId so only set customDataEntity when using blocks*} + {assign var="element_name" value=$element.element_custom_name} + {assign var="formElement" value=$form.$customDataEntity.$blockId.$element_name} + {else} + {assign var="element_name" value=$element.element_name} + {assign var="formElement" value=$form.$element_name} + {/if} + {include file="CRM/Custom/Form/Edit/CustomField.tpl"} + {/foreach} +
+
+{if $cd_edit.help_post}
{$cd_edit.help_post}
{/if} +{if !$isSingleRecordEdit && $cd_edit.is_multiple and ( ( $cd_edit.max_multiple eq '' ) or ( $cd_edit.max_multiple > 0 and $cd_edit.max_multiple > $cgCount ) ) } + {if $skipTitle} + {* We don't yet support adding new records in inline-edit forms *} +
+ {ts 1=$cd_edit.title}Click "Edit Contact" to add more %1 records{/ts} +
+ {else} + + {/if} +{/if} + +{*set customDataEntity to null to prevent leakage if this is called more than once*} +{assign var='customDataEntity' value=''}