Php savesugarcrm上的Javascript

Php savesugarcrm上的Javascript,php,javascript,sugarcrm,Php,Javascript,Sugarcrm,我正在尝试在sugarcrm中为notes模块创建一个弹出窗口。当用户单击Save Note时,我想验证字段notes_c是否为空。如果它是空的,我想弹出一个错误,说这张便条是空的。他们可以通过任何方式取消或保存。下面是我添加的代码,但无法显示弹出窗口 我将按钮添加到custom/modules/Notes/metadata/editviewdefs.php array ( 'enctype' => 'multipart/form-data', 'headerTpl'

我正在尝试在sugarcrm中为notes模块创建一个弹出窗口。当用户单击Save Note时,我想验证字段notes_c是否为空。如果它是空的,我想弹出一个错误,说这张便条是空的。他们可以通过任何方式取消或保存。下面是我添加的代码,但无法显示弹出窗口

我将按钮添加到custom/modules/Notes/metadata/editviewdefs.php

  array (
    'enctype' => 'multipart/form-data',
    'headerTpl' => 'modules/Notes/tpls/EditViewHeader.tpl',
    'buttons' => array(
                        array('customCode'=>'<input id="samples_transfer_save" type="submit" value="Save Note" name="button" onclick="this.form.action.value=\'Save\'; return (check_save() && check_form(\'EditView\'));"  class="button" accesskey="S" title="Save [Alt+S]"/>&nbsp;'),
                        'CANCEL',
       ),
  ),
  'includes'=> array('file'=>'custom/modules/Notes/checksave.js'),

最好的方法是转到Studio,编辑notes_c字段,并选中Required field复选框。这将为您进行验证

如果您坚持添加自己的js进行验证,那么您可以保留默认按钮,但在js文件中会覆盖onsubmit函数

document.EditView.onsubmit = check_save;

最好的方法是转到Studio,编辑notes_c字段,并选中Required field复选框。这将为您进行验证

如果您坚持添加自己的js进行验证,那么您可以保留默认按钮,但在js文件中会覆盖onsubmit函数

document.EditView.onsubmit = check_save;

要在SugarCRM中添加自定义脚本,请执行以下操作:

在logic_hook.php中

<?php

$hook_version = 1;
$hook_array = Array();

$hook_array['after_ui_frame'] = Array();
$hook_array['after_ui_frame'][] = Array(1, 'JQuery', 'custom/modules/Accounts/custom_code/customscripts.php','JQuery', 'JQuery'); 

?>
在jquery类文件中

<?php

class JQuery{

    function JQuery($event, $arguments){
        echo '<script type="text/javascript" src="custom/modules/Accounts/custom_code/jmask.js"></script>';
        echo '<script type="text/javascript" src="custom/modules/Accounts/custom_code/scripts.js"></script>';           
    }

}
?>

创建名为scripts的普通JS文件并导入jmask。

要在SugarCRM中添加自定义脚本,我执行以下操作:

在logic_hook.php中

<?php

$hook_version = 1;
$hook_array = Array();

$hook_array['after_ui_frame'] = Array();
$hook_array['after_ui_frame'][] = Array(1, 'JQuery', 'custom/modules/Accounts/custom_code/customscripts.php','JQuery', 'JQuery'); 

?>
在jquery类文件中

<?php

class JQuery{

    function JQuery($event, $arguments){
        echo '<script type="text/javascript" src="custom/modules/Accounts/custom_code/jmask.js"></script>';
        echo '<script type="text/javascript" src="custom/modules/Accounts/custom_code/scripts.js"></script>';           
    }

}
?>
创建名为scripts的普通JS文件并导入jmask