ExtJS 4 - Mark a red asterisk on an required field

后端 未结 11 2275
长发绾君心
长发绾君心 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:53

    I have a little bit shorter solution. I suggest to use form's 'beforeadd' event like this:

    Ext.define('Ext.ux.form', {
        extend: 'Ext.form.Panel',
        initComponent: function() {
          this.on('beforeadd', function(me, field){
            if (!field.allowBlank)
              field.labelSeparator += '*';
          });
          this.callParent(arguments);
        }
    });
    

    Here is demo

提交回复
热议问题