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

后端 未结 2 418
后悔当初
后悔当初 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.

提交回复
热议问题