Skip to content

Commit

Permalink
Fix help for financial acls.
Browse files Browse the repository at this point in the history
I've done this by using the field template that is used by entity forms & adding
help to the spec (which I'll document).

I noted in this that entityTrait used a different field key for the
documentation link - literally documentation_link whereas I had used field_link
so I fixed settings to match
  • Loading branch information
eileenmcnaughton committed Nov 4, 2018
1 parent 1d6f59e commit 969afb1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 32 deletions.
7 changes: 1 addition & 6 deletions CRM/Admin/Form/SettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ protected function addFieldsDefinedInSettingsMetadata() {
$this->includesReadOnlyFields = TRUE;
}

if (isset($props['help_link'])) {
// Set both the value in this loop & the outer value as we assign both to the template while we deprecate the $descriptions assignment.
$settingMetaData[$setting]['description'] = $props['description'] .= ' ' . CRM_Utils_System::docURL2($props['help_link']['page'], NULL, NULL, NULL, NULL, $props['help_link']['resource']);

}
$add = 'add' . $quickFormType;
if ($add == 'addElement') {
$this->$add(
Expand All @@ -162,7 +157,7 @@ protected function addFieldsDefinedInSettingsMetadata() {
$this->addElement('select', $setting, ts($props['title']), $options, CRM_Utils_Array::value('html_attributes', $props));
}
elseif ($add == 'addCheckBox') {
$this->addCheckBox($setting, ts($props['title']), $options, NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, ['  ']);
$this->addCheckBox($setting, '', $options, NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, ['  ']);
}
elseif ($add == 'addCheckBoxes') {
$options = array_flip($options);
Expand Down
1 change: 1 addition & 0 deletions settings/Contribute.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
'is_contact' => 0,
'description' => NULL,
'help_text' => NULL,
'help' => ['id' => 'acl_financial_type'],
),
'deferred_revenue_enabled' => array(
'group_name' => 'Contribute Preferences',
Expand Down
2 changes: 1 addition & 1 deletion settings/Event.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'is_contact' => 0,
'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it'),
'help_text' => '',
'help_link' => ['page' => 'CiviEvent Cart Checkout', 'resource' => 'wiki'],
'documentation_link' => ['page' => 'CiviEvent Cart Checkout', 'resource' => 'wiki'],
),
'show_events' => array(
'name' => 'show_events',
Expand Down
2 changes: 1 addition & 1 deletion settings/Multisite.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'is_domain' => 1,
'is_contact' => 0,
'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled'),
'help_link' => ['page' => 'Multi Site Installation', 'resource' => 'wiki'],
'documentation_link' => ['page' => 'Multi Site Installation', 'resource' => 'wiki'],
'help_text' => NULL,
),
'domain_group_id' => array(
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Core/Form/Field.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
</td>
<td>{if $form.$fieldName.html}{if $fieldSpec.formatter === 'crmMoney'}{$form.$fieldName.html|crmMoney}{else}{$form.$fieldName.html}{/if}{else}{$fieldSpec.place_holder}{/if}<br />
{if $fieldSpec.description}<span class="description">{$fieldSpec.description}</span>{/if}
{if $fieldSpec.documentation_link}{docURL page=$fieldSpec.documentation_link.page}{/if}
{if $fieldSpec.documentation_link}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
</td>
{/if}
29 changes: 6 additions & 23 deletions templates/CRM/Form/basicFormFields.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,11 @@
*}
{* @todo with a small amount of tinkering most of this can be replaced by re-using the foreach loop in CRM_Core_EntityForm.tpl *}
<table class="form-layout">
{foreach from=$fields item=field key=fieldName}
{assign var=n value=$fieldName}
{if $form.$n}
<tr class="crm-preferences-form-block-{$fieldName}">
{if $field.html_type EQ 'checkbox'|| $field.html_type EQ 'checkboxes'}
<td class="label"></td>
<td>
{$form.$n.html}
{if $field.description}
<br /><span class="description">{$field.description}</span>
{/if}
</td>
{else}
<td class="label">{$form.$n.label}</td>
<td>
{$form.$n.html}
{if $field.description}
<br /><span class="description">{$field.description}</span>
{/if}
</td>
{/if}
</tr>
{/if}

{foreach from=$fields item=fieldSpec}
{assign var=fieldName value=$fieldSpec.name}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{/foreach}
</table>

0 comments on commit 969afb1

Please sign in to comment.