ExtJs: Form isValid() is false. But how to know why the form is invalid?

后端 未结 2 346
后悔当初
后悔当初 2021-01-31 19:56

I am using an ExtJs form having a file upload field in it. On selecting a file I am calling the submit() method of the form. But before submitting I am checking if the form is

相关标签:
2条回答
  • 2021-01-31 20:25

    You can try adding the following function to your Form Panel definition:

    getInvalidFields: function() {
        var invalidFields = [];
        Ext.suspendLayouts();
        this.form.getFields().filterBy(function(field) {
            if (field.validate()) return;
            invalidFields.push(field);
        });
        Ext.resumeLayouts(true);
        return invalidFields;
    }
    

    It will return an array containing only those fields that were evaluated as invalid, here is a working example.

    0 讨论(0)
  • 2021-01-31 20:43

    Here's a much simpler solution:

    form.query("field{isValid()==false}")
    
    0 讨论(0)
提交回复
热议问题