首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SuiteCRM自定义重复验证不会保存或更新

问SuiteCRM自定义重复验证不会保存或更新
EN

Stack Overflow用户
提问于 2022-10-24 06:56:52
回答 1查看 26关注 0票数 0

日安!

我在我的SuiteCRM上创建了一个自定义验证,如果它已经存在,它将验证名字、姓氏和移动号码。但我的问题是,在验证工作完成后,数据不会保存或更新。

检查我的view.edit.php代码如下:

代码语言:javascript
复制
$javascript = <<<'EOT'
    <script type="text/javascript" language="JavaScript">
    function customJavascriptDuplicateValidation(thisview)
    {
        var firstname = document.getElementById('first_name').value;
        var lastname = document.getElementById('last_name').value;
        var mobile = document.getElementById('mobile_number').value;
        var birthday = document.getElementById('birthday').value;
        var email = document.getElementById('email_c').value;
        var location = document.getElementById('location_code').value;
        var consent = document.getElementById('consent_timestamp_date').value;
        var salutation = document.getElementById('salutation').value;
        
        $.post('index.php?entryPoint=checkDuplicateCustomers', { first_name: firstname, last_name: lastname, mobile_number: mobile }, function(data)
        {
            if (data == 'exists') {
                $('#error_firstname_msg').html('<strong style="color:red;"> &#x2717; Already Used</strong>');
                $('#error_lastname_msg').html('<strong style="color:red;"> &#x2717; Already Used</strong>');
                $('#error_mobile_msg').html('<strong style="color:red;"> &#x2717; Already Used</strong>');
                return check_form('EditView');
            }else if (data == 'unique'){
                $('#error_firstname_msg').hidden;
                $('#error_lastname_msg').hidden;
                $('#error_mobile_msg').hidden;
                if(firstname != '' && lastname != '' && mobile != '' && birthday != '' && email != '' && location != '' && consent != '' && salutation != ''){
                    return check_form('EditView');
                }else{
                    return check_form('EditView');
                }
            }else{
                $('#error_firstname_msg').hidden;
                $('#error_lastname_msg').hidden;
                $('#error_mobile_msg').hidden;
                return check_form('EditView');
            }
        });
        
    }
    </script>
    EOT;

我在editviewdefs.php修改了保存按钮

代码语言:javascript
复制
$viewdefs['Accounts']['EditView']['templateMeta']['form']['buttons'][0] = array(
'customCode' => '<input title="Save" accesskey="a" class="button primary" onclick="var _form = document.getElementById(\'EditView\'); _form.action.value=\'Save\'; if(customJavascriptDuplicateValidation(\'EditView\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="Save" id="SAVE">',);

当您单击保存时,本机Valition可以工作。

​

如果单击保存,则自定义验证也有效:

​

​

​

在填写所需字段并输入独特的客户信息之后。数据不会保存。

我对此的结论是我的定制javascript代码。因为如果我将代码放在$.POST函数之外,数据将保存,但如果条件中的所有字段都不是空/空,则自定义重复验证将无法工作。

代码语言:javascript
复制
if(firstname != '' && lastname != '' && mobile != '' && birthday != '' && email != '' && location != '' && consent != '' && salutation != ''){
                     SUGAR.ajaxUI.showLoadingPanel();
                    return check_form('EditView');
                }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-26 08:50:21

请不要考虑这个问题,我只需在下面添加以下代码就可以修复这个问题:

代码语言:javascript
复制
                SUGAR.ajaxUI.showLoadingPanel();
                var _form = document.getElementById('EditView');
                    _form.action.value='Save';
                SUGAR.ajaxUI.submitForm(_form);
                return check_form('EditView'); 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74177526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档