ExtJS 4 - Mark a red asterisk on an required field

后端 未结 11 2052
长发绾君心
长发绾君心 2020-12-08 08:24

I have this problem where I need to add a red asterisk beside a fieldLabel when a field is marked as \"required\" (or allowBlank: false)

In

11条回答
  •  有刺的猬
    2020-12-08 08:36

    You can also override and extend nothing and just create a controller action like so:

    Ext.define('MyApp.controller.MyForm', {
        extend: 'Ext.app.Controller',
    
        markMandatoryFields: function(field, options) {
            if (field && field.isFieldLabelable && field.fieldLabel && field.allowBlank == false) {
                field.fieldLabel += ' *';
            }
        },
    
        init: function() {
            this.control({
                "field": {
                    beforerender: this.markMandatoryFields
                }
            });
        }
    });
    

提交回复
热议问题