从Sugarcrm中的QuickCreate中删除必填字段

时间:2013-03-11 06:51:51

标签: javascript sugarcrm

我写了一个函数来删除Contacts QuickCreate中的帐户名称相关字段,但我的功能完全适用于Firefox,但在chrome中它不起作用......这是我的功能

function manageRequired(reqArr, disabledVal)
{
    var requiredLabel = '<span class="required">*</span>'; // for firefox
    var search_requiredLabel = '<span class="required"'; // searching string for firefox
    var form = "";

    for(var i = 0; i < document.forms.length; i++)
    {
        if(document.forms[i].id=='EditView')
        {
            form = 'EditView';
            break;
        }
        if(document.forms[i].id=='form_SubpanelQuickCreate_Contacts')
        {
            form = 'form_SubpanelQuickCreate_Contacts';
            break;
            }
        if(document.forms[i].id=='form_QuickCreate_Contacts')
        {
            form = 'form_QuickCreate_Contacts';
            break;
            }
        if(document.forms[i].id=='form_QuickCreate_Accounts')
        {
            form = 'form_QuickCreate_Accounts';
            break;
            }
    }
    for(var j = 0; j < reqArr.length; j++)
    {
        var flag = true;
        if (validate[form] != 'undefined') 
        {
            for(var i = 0; i < validate[form].length; i++)
            {
                if(validate[form][i][0] == reqArr[j].id && validate[form][i][2])
                {
                    if(disabledVal)
                    {
                        flag = false;
                        break;
                    }
                    else
                    {
                        validate[form][i][2] = false;
                    }
                }
            }
        }
        var labelNode = document.getElementById(reqArr[j].id + '_label');
        if(flag & disabledVal)
        {
            // we require the field now
            addToValidate(form, reqArr[j].id, reqArr[j].type, true,reqArr[j].label );
        }
        if(disabledVal)
        {
            if(labelNode != null && labelNode.innerHTML.indexOf(search_requiredLabel) == -1) // for IE replace search string
            {
                search_requiredLabel = '<SPAN class=required>';
            }
            if (labelNode != null && labelNode.innerHTML.indexOf(search_requiredLabel) == -1) 
            {
                labelNode.innerHTML = labelNode.innerHTML.replace(requiredLabel, '');
                labelNode.innerHTML = labelNode.innerHTML + requiredLabel;
            }
        }
        else
        {
            if(labelNode != null)
            {
                if(labelNode != null && labelNode.innerHTML.indexOf("<SPAN class=required>*</SPAN>") == -1 && labelNode.innerHTML.indexOf('<span class="required">*</span>') == -1 )// for that field which is unrequired
                {
                }
                else if(labelNode != null && labelNode.innerHTML.indexOf(requiredLabel) == -1) // for IE replace span string
                {
                    requiredLabel = "<SPAN class=required>*</SPAN>";
                }
                labelNode.innerHTML = labelNode.innerHTML.replace(requiredLabel, '');
            }
        }
    }
}

任何人都可以帮我解决这个问题......

1 个答案:

答案 0 :(得分:1)

要从 Sugarcrm 中的 QuickCreate 中删除必填字段,您可以使用此功能:

removeFromValidate('EditView','eventlist_c');

或删除删除应用于该字段的验证:

$('#eventlist_c_label').html('{$mod_strings['LBL_EVENTLIST']}: ');