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
An approach that you might find more elegant is adding a css class to any field label that is marked with allowBlank=false
and style your mandatory indicator in CSS.
Ext.define('Ext.ux.form', {
extend: 'Ext.form.Panel',
listeners: {
'beforeadd': function(){
if (!field.allowBlank) {
field.labelClsExtra = 'x-required';
}
}
}
});
You can then style your field label in CSS with an :after
pseudo utility:
.x-required:after {
content: ' *';
color: red;
font-weight: bold;
}