extjs - Add color to fieldlabel -


i put red asterisk after fieldlabel in order user must fill field. there way add directly css code in js code? parameter style example asterisk

var blablafield  = new ext.form.textfield({ fieldlabel : 'name *', allowblank : false, width : 300 }); 

you have @ least 3 (imo) clean ways archive this:

to automatically field didn't allow blank should use custom form extension this.

ext.define('ext.ux.form', {     extend: 'ext.form.panel',     initcomponent: function() {       var me = this;       me.on('beforeadd', function(form, field){         if (!field.allowblank)           field.labelseparator += '<span style="color: rgb(255, 0, 0); padding-left: 2px;">*</span>';       });       me.callparent(arguments);     } }); 

if want 1 field can use afterlabeltexttpl or afterlabeltpl config property , apply

<span style="color: rgb(255, 0, 0); padding-left: 2px;">*</span> 

or can add directly label-text

fieldlabel : 'name<span style="color: rgb(255, 0, 0); padding-left: 2px;">*</span>' 

where first 1 because need nothing expect setting required flag.

edit

if don't wan't apply asterix field not allow blank when get's added form may introduce new property skiplabelappendix. may set property field should not asterix appended after label. , don't forget include form so

me.on('beforeadd', function(form, field){     if (!field.allowblank && !field.skiplabelappendix)        field.labelseparator += '<span style="color: rgb(255, 0, 0); padding-left: 2px;">*</span>';       }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -