日安!
我在我的SuiteCRM上创建了一个自定义验证,如果它已经存在,它将验证名字、姓氏和移动号码。但我的问题是,在验证工作完成后,数据不会保存或更新。
检查我的view.edit.php代码如下:
$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;"> ✗ Already Used</strong>');
$('#error_lastname_msg').html('<strong style="color:red;"> ✗ Already Used</strong>');
$('#error_mobile_msg').html('<strong style="color:red;"> ✗ 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修改了保存按钮
$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函数之外,数据将保存,但如果条件中的所有字段都不是空/空,则自定义重复验证将无法工作。
if(firstname != '' && lastname != '' && mobile != '' && birthday != '' && email != '' && location != '' && consent != '' && salutation != ''){
SUGAR.ajaxUI.showLoadingPanel();
return check_form('EditView');
}发布于 2022-10-26 08:50:21
请不要考虑这个问题,我只需在下面添加以下代码就可以修复这个问题:
SUGAR.ajaxUI.showLoadingPanel();
var _form = document.getElementById('EditView');
_form.action.value='Save';
SUGAR.ajaxUI.submitForm(_form);
return check_form('EditView'); https://stackoverflow.com/questions/74177526
复制相似问题