salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.5k stars 2.09k forks source link

Error in themes/SuiteP/include/EditView/tab_panel_content.tpl for custom code #6933

Open cartbar opened 5 years ago

cartbar commented 5 years ago

Issue

I have defined custom code is the editviewdefs.php of my custom module, thus:

          0 => array(
            'name' => 'name',
            'customCode' => '{literal}<script type="text/javascript"></script>{/literal}',
            'customCodeRenderField' => true,
          ),

Expected Behavior

When viewing the edit screen I should get the following HTML:

<div class="col-xs-12 col-sm-6 edit-view-row-item">
   <div class="col-xs-12 col-sm-4 label" data-label="LBL_NAME">
      WMS Account Id:<span class="required">*</span>
   </div>
   <div class="col-xs-12 col-sm-8 edit-view-field " type="name" field="name">
     <input type="text" name="name" id="name" size="30" maxlength="9" value="WIR123456" title="">
     <script type="text/javascript"></script>
  </div>

Actual Behavior

I get the following HTML:

<div class="col-xs-12 col-sm-6 edit-view-row-item">
    <div class="col-xs-12 col-sm-4 label" data-label="LBL_NAME">
        WMS Account Id:<span class="required">*</span>
   </div>
   <div class="col-xs-12 col-sm-8 edit-view-field " type="name" field="name">
      <input type="text" name="name" id="name" size="30" maxlength="9" value="WIR123456" title="">
      2
      <script type="text/javascript"></script>
   </div>

i.e. there is a "2" after the input field

Possible Fix

It appears that there is a typo in themes/SuiteP/include/EditView/tab_panel_content.tpl:

113                             {{if !empty($colData.field.customCode) && !empty($colData.field.customCodeRenderField)}}
114                                 {counter name="panelFieldCount"}
115                                 {{sugar_evalcolumn var=$colData.field.customCode colData=$        colData tabindex=$colData.field.tabindex}}
116                             {{/if}}

Should be:

113                             {{if !empty($colData.field.customCode) && !empty($colData.field.customCodeRenderField)}}
114                                 {counter name="panelFieldCount" print="false"}
115                                 {{sugar_evalcolumn var=$colData.field.customCode colData=$        colData tabindex=$colData.field.tabindex}}
116                             {{/if}}

Your Environment

willrennie commented 5 years ago

@cartbar I'm not seeing the typo myself and your possible fix shows two code snippets which appear to be identical. Can you check and review?

cartbar commented 5 years ago

Hello.

Please look at line 114 on both code sections and you will see 'print="false"' in the second one but not in the first.

Regards

willrennie commented 5 years ago

@cartbar thanks for the further information. I've added your code to the editviewdefs.php but I'm not seeing the issue. Can you clarify exactly where you're making changes, in which module i.e. if it's a custom module are you making the change in the core modules dir or in custom, can you also show screen shots of how your layout is looking and maybe a console snippet or output on the browser of where the number 2 is output? Thanks.

cartbar commented 5 years ago

As I said in my initial post: "I have defined custom code is the editviewdefs.php of my custom module"

Specifically, the editviewdefs.php file is in /modules/metadata/editviewdefs.php:

$module_name` = ''; $viewdefs [$module_name] = array ( 'EditView' => array ( 'templateMeta' => array ( 'maxColumns' => '2', 'widths' => array ( 0 => array ( 'label' => '10', 'field' => '30', ), 1 => array ( 'label' => '10', 'field' => '30', ), ), 'useTabs' => false, 'tabDefs' => array ( 'DEFAULT' => array ( 'newTab' => false, 'panelDefault' => 'expanded', ), ), ), 'panels' => array ( 'default' => array ( 0 => array ( 0 => array( 'name' => 'name', 'customCode' => '{if !empty($smarty.request.nameError)}{literal}{/literal}{/if}', 'customCodeRenderField' => true, ), 1 => 'assigned_username', ), 1 => array ( 0 => array ( 'name' => '...', 'label' => 'LBL..._TITLE', ), ), ), ), ), ); ; ?>

Without the change to the template, with I edit a record I get:

image

You can see the "2" after the field