Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#527 Add in abiity to set translated text for Submit and Canc… #13185

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CRM/Core/DAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/UFGroup.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:e5e629c4f6d56d238b4ac28e822cea8a)
* (GenCodeChecksum:0f78fb49440e1cf5d43fd3db5a43ee7e)
*/

/**
Expand Down Expand Up @@ -551,6 +551,9 @@ public static function &fields() {
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 1,
'html' => [
'type' => 'Text',
],
],
'submit_button_text' => [
'name' => 'submit_button_text',
Expand All @@ -564,6 +567,9 @@ public static function &fields() {
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 1,
'html' => [
'type' => 'Text',
],
],
'add_cancel_button' => [
'name' => 'add_cancel_button',
Expand Down
8 changes: 6 additions & 2 deletions CRM/UF/Form/AdvanceSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group {
* @param CRM_Core_Form $form
*/
public static function buildAdvanceSetting(&$form) {
$entityFields = [
'cancel_button_text',
'submit_button_text',
];
$form->assign('advancedFieldsConverted', $entityFields);

// should mapping be enabled for this group
$form->addElement('checkbox', 'is_map', ts('Enable mapping for this profile?'));

Expand All @@ -53,8 +59,6 @@ public static function buildAdvanceSetting(&$form) {

$form->add('advcheckbox', 'add_cancel_button', ts('Include Cancel Button?'));
$form->addElement('text', 'cancel_URL', ts('Cancel Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_URL'));
$form->addElement('text', 'cancel_button_text', ts('Cancel Button Text'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_button_text'));
$form->addElement('text', 'submit_button_text', ts('Submit Button Text'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'submit_button_text'));

// add select for groups
$group = array('' => ts('- select -')) + $form->_group;
Expand Down
4 changes: 3 additions & 1 deletion CRM/UF/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ protected function setEntityFields() {
'title' => ['name' => 'title'],
'frontend_title' => ['name' => 'frontend_title'],
'description' => ['name' => 'description', 'help' => ['id' => 'id-description', 'file' => 'CRM/UF/Form/Group.hlp']],
'uf_group_type' => ['name' => 'uf_group_type', 'not-auto-addable' => TRUE, 'help' => ['id' => 'id-used_for', 'file' => 'CRM/UF/Form/Group.hlp'], 'post_html_text' => ' ' . $this->getOtherModuleString()]
'uf_group_type' => ['name' => 'uf_group_type', 'not-auto-addable' => TRUE, 'help' => ['id' => 'id-used_for', 'file' => 'CRM/UF/Form/Group.hlp'], 'post_html_text' => ' ' . $this->getOtherModuleString()],
'cancel_button_text' => ['name' => 'cancel_button_text', 'help' => ['id' => 'id-cancel_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => 'cancel_button_section'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton note the class here is because of some javascript that hides all cancel button sections if the show cancel button field is not checked

'submit_button_text' => ['name' => 'submit_button_text', 'help' => ['id' => 'id-submit_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => ''],
];
}

Expand Down
15 changes: 6 additions & 9 deletions templates/CRM/UF/Form/AdvanceSetting.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@
<td>{$form.cancel_URL.html} {help id='id-cancel_URL' file="CRM/UF/Form/Group.hlp"}</td>
</tr>

<tr class="cancel_button_section crm-uf-advancesetting-form-block-cancel_button_text">
<td class="label">{$form.cancel_button_text.label}</td>
<td>{$form.cancel_button_text.html} {help id='id-cancel_button_text' file="CRM/UF/Form/Group.hlp"}</td>
</tr>

<tr class="crm-uf-advancesetting-form-block-submit_button_text">
<td class="label">{$form.submit_button_text.label}</td>
<td>{$form.submit_button_text.html} {help id='id-submit_button_text' file="CRM/UF/Form/Group.hlp"}</td>
</tr>
{foreach from=$advancedFieldsConverted item=fieldName}
{assign var=fieldSpec value=$entityFields.$fieldName}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName} {$fieldSpec.class}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{/foreach}

<tr class="crm-uf-advancesetting-form-block-add_captcha">
<td class="label"></td>
Expand Down
10 changes: 6 additions & 4 deletions templates/CRM/UF/Form/Group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
{else}
<table class="form-layout">
{foreach from=$entityFields item=fieldSpec}
{assign var=fieldName value=$fieldSpec.name}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{if not in_array($fieldSpec.name, $advancedFieldsConverted)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that the new fields don't show on the main part of the form as well as on the advanced settings section

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not hugely important but I think !in_array would be more consistent with elsewhere than 'not'

{assign var=fieldName value=$fieldSpec.name}
<tr class="crm-{$entityInClassFormat}-form-block-{$fieldName}">
{include file="CRM/Core/Form/Field.tpl"}
</tr>
{/if}
{/foreach}
<tr class="crm-uf_group-form-block-weight" >
<td class="label">{$form.weight.label}{if $config->userSystem->is_drupal EQ '1'} {help id='id-profile_weight' file="CRM/UF/Form/Group.hlp"}{/if}</td>
Expand Down
6 changes: 6 additions & 0 deletions xml/schema/Core/UFGroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@
<default>NULL</default>
<localizable>true</localizable>
<add>4.7</add>
<html>
<type>Text</type>
</html>
</field>
<field>
<name>submit_button_text</name>
Expand All @@ -291,6 +294,9 @@
<default>NULL</default>
<localizable>true</localizable>
<add>4.7</add>
<html>
<type>Text</type>
</html>
</field>
<field>
<name>add_cancel_button</name>
Expand Down