Skip to content

Commit

Permalink
Enable & do single field metadata conversion for defaultContactCountry
Browse files Browse the repository at this point in the history
This builds on civicrm#19629

Our intention is that we should be building functionality into this
form that is actually used in core. It's a bit tricky to swap out
all fields at once but this makes them individually swap-outable.

Only defaultContactCountry is swapped out. I looked a little at the
help_text issue - the text actually does work if you
add it since it's already in the hlp file but I decided this
broke consistency less (using description) as other fields
on the form do that and look similar. Also, when the text is
really just a bit of text (not a long help text) it makes sense.

(Otherwise I'd need to trawl through resolving the bigger issue
and I didn't want to bring that into scope)
  • Loading branch information
eileenmcnaughton committed Mar 1, 2021
1 parent 0843757 commit 32c46af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
7 changes: 2 additions & 5 deletions templates/CRM/Admin/Form/Setting/Localization.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<td class="label">{$form.moneyformat.label} {help id='moneyformat' title=$form.moneyformat.label}</td>
<td>{$form.moneyformat.html}</td>
</tr>
<tr class="crm-localization-form-block-customTranslateFunction">
<tr class="crm-localization-form-block-customTranslateFunction">
<td class="label">{$form.customTranslateFunction.label} {help id='customTranslateFunction' title=$form.customTranslateFunction.label}</td>
<td>{$form.customTranslateFunction.html}</td>
</tr>
Expand All @@ -84,10 +84,7 @@
</table>
<h3>{ts}Contact Address Fields - Selection Values{/ts}</h3>
<table class="form-layout-compressed">
<tr class="crm-localization-form-block-defaultContactCountry">
<td class="label">{$form.defaultContactCountry.label} {help id='defaultContactCountry' title=$form.defaultContactCountry.label}</td>
<td>{$form.defaultContactCountry.html}</td>
</tr>
{include file='CRM/Admin/Form/Setting/SettingField.tpl' setting_name='defaultContactCountry' fieldSpec=$settings_fields.defaultContactCountry}
<tr class="crm-localization-form-block-pinnedContactCountries">
<td class="label">{$form.pinnedContactCountries.label} {help id='pinnedContactCountries' title=$form.pinnedContactCountries.label}</td>
<td>{$form.pinnedContactCountries.html}</td>
Expand Down
17 changes: 17 additions & 0 deletions templates/CRM/Admin/Form/Setting/SettingField.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{* Display setting field from metadata - todo consolidate with CRM_Core_Form_Field.tpl *}
<tr class="crm-setting-form-block-{$setting_name}">
<td class="label">{$form.$setting_name.label}</td>
<td>
{if !empty($fieldSpec.wrapper_element)}
{$fieldSpec.wrapper_element.0}{$form.$setting_name.html}{$fieldSpec.wrapper_element.1}
{else}
{$form.$setting_name.html}
{/if}
<div class="description">
{$fieldSpec.description}
</div>
{if $fieldSpec.help_text}
{assign var='tplhelp_id' value = $setting_name|replace:'_':'-'}{help id="$tplhelp_id"}
{/if}
</td>
</tr>
19 changes: 2 additions & 17 deletions templates/CRM/Admin/Form/Setting/SettingForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,8 @@
*}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class="form-layout-compressed">
{foreach from=$settings_fields key="setting_name" item="setting_detail"}
<tr class="crm-mail-form-block-{$setting_name}">
<td class="label">{$form.$setting_name.label}</td>
<td>
{if !empty($setting_detail.wrapper_element)}
{$setting_detail.wrapper_element.0}{$form.$setting_name.html}{$setting_detail.wrapper_element.1}
{else}
{$form.$setting_name.html}
{/if}
<div class="description">
{$setting_detail.description}
</div>
{if $setting_detail.help_text}
{assign var='tplhelp_id' value = $setting_name|cat:'-id'|replace:'_':'-'}{help id="$tplhelp_id"}
{/if}
</td>
</tr>
{foreach from=$settings_fields key="setting_name" item="fieldSpec"}
{include file="CRM/Admin/Form/Setting/SettingField.tpl"}
{/foreach}
</table>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
Expand Down

0 comments on commit 32c46af

Please sign in to comment.