dev/core#527 Add in abiity to set translated text for Submit and Cancel button text
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 30 Nov 2018 06:26:53 +0000 (06:26 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 28 Dec 2018 09:35:12 +0000 (20:35 +1100)
Convert to using entity fields style adding to form

CRM/Core/DAO/UFGroup.php
CRM/UF/Form/AdvanceSetting.php
CRM/UF/Form/Group.php
templates/CRM/UF/Form/AdvanceSetting.tpl
templates/CRM/UF/Form/Group.tpl
xml/schema/Core/UFGroup.xml

index af151133392340cf2f0f02db98b1d341398d02f4..27bfa1f2a3fb65b4763e26ce5fc1d2f37b63b82c 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Core/UFGroup.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:e5e629c4f6d56d238b4ac28e822cea8a)
+ * (GenCodeChecksum:0f78fb49440e1cf5d43fd3db5a43ee7e)
  */
 
 /**
@@ -551,6 +551,9 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
           'localizable' => 1,
+          'html' => [
+            'type' => 'Text',
+          ],
         ],
         'submit_button_text' => [
           'name' => 'submit_button_text',
@@ -564,6 +567,9 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
           'localizable' => 1,
+          'html' => [
+            'type' => 'Text',
+          ],
         ],
         'add_cancel_button' => [
           'name' => 'add_cancel_button',
index 4c872910d193df5faef8eb71d690504a7b12578a..f2945f63dad899b8b961cd98b83ede827dd7c430 100644 (file)
@@ -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?'));
 
@@ -53,8 +59,6 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group {
 
     $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;
index 475485d293d1fefb6957e252a9348662036ed153..a1c2d80f47352f3a9482c3f1c52a174446635d63 100644 (file)
@@ -64,7 +64,9 @@ class CRM_UF_Form_Group extends CRM_Core_Form {
       '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'],
+      'submit_button_text' => ['name' => 'submit_button_text', 'help' => ['id' => 'id-submit_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => ''],
     ];
   }
 
index c2ba1ecf6336986082642df2a416f2fc0180c848..dcef516824914ea220fad8091d339fae0a5be0c5 100644 (file)
             <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>
index 698e71e05d03b5937b2adf54b7a905da4e8d4353..7e96dd6f640c28107b9d448e0b30c3c2c015c35b 100644 (file)
 {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)}
+          {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>
index 4057e3bd9fdb812327fa5de77394d62e7e4f314e..cafe160ac631ff8e3fd012a0b4e437ae0ebe9b32 100644 (file)
     <default>NULL</default>
     <localizable>true</localizable>
     <add>4.7</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <field>
     <name>submit_button_text</name>
     <default>NULL</default>
     <localizable>true</localizable>
     <add>4.7</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <field>
     <name>add_cancel_button</name>