Friday, July 23, 2010

ExtJS - adding a asterisk '*' sign in red color for all required or mandatory field.

Well there was a requirement in ExtJS where all the mandatory/required fields in the application (i.e allowNull is false) should have a * sign in red color.

Here is the code which adds a * (asterisk) sign in red color to the field label while rendering for all the required fields in your application.

// This code adds the * sign for all the field labels if the fields are mandatory
Ext.apply(Ext.layout.FormLayout.prototype, {
originalRenderItem: Ext.layout.FormLayout.prototype.renderItem,
renderItem: function(c, position, target){
if (c && !c.rendered && c.isFormField && c.fieldLabel && !c.allowBlank) {
c.fieldLabel = c.fieldLabel + " ((c.requiredFieldCls !== undefined) ? 'class="' + c.requiredFieldCls + '"' : 'style="color:red;font-size: 11px;"') +
">*
";
}
this.originalRenderItem.apply(this, arguments);
}
});

1 comment:

yahoomovies said...

excellent collection thanks for posting songs...


also follow yahoomelody