Amitesh Kumar
Amitesh Kumar

Reputation: 3079

Conditional validation on field in subpanel Sugarcrm

I have a drop-down field status 'yes','no' . if status is yes then description field is required else not required.

I write a custom code for create and record view , By using this help

Validation on record view

And it is working fine. In sub panel validation is not working . I search on Google but did not find any solution.

Upvotes: 0

Views: 759

Answers (1)

Amitesh Kumar
Amitesh Kumar

Reputation: 3079

I found the answer . I we want to give validation to field on sub panel or list view then, create file like this.

custom\modules\Leads\clients\base\fields\editablelistbutton\editablelistbutton.js

in editablelistbutton.js

({

extendsFrom:'EditablelistbuttonField',

initialize:function(options){
        this._super('initialize',[options]);
        this.model.addValidationTask('check_acceptable', _.bind(this._doValidateComment, this));
},

 _doValidateComment: function(fields, errors, callback) {
        //validate type requirements.
        if (this.model.get('acceptable') == 'no' )
        {
            errors.comment_c = errors.account_services_c || {};
            errors.comment_c.required = true;
        }
        callback(null, fields, errors);
    },
});

IT is working for me .

Upvotes: 1

Related Questions