PDA

View Full Version : Highlighting Required Fields



nak1
25 Jun 2009, 7:46 AM
I've got a form that I'm "transforming" using the "applyTo" attributes in the Ext.form.Field object and I was wondering if anyone has an override/apply method that would change the style of the field if the allowBlank was false. That way the user knows that the field is required. Unfortunately, I'm not using form labels, so I'll need a simple means of doing this to the field object itself.

Thanks.

Animal
25 Jun 2009, 8:55 AM
Simple isn't it?

Override Field.onRender using createSequence and add a CSS class if allowBlank is false.

TopKatz
25 Jun 2009, 9:35 AM
I have used this in the past on forms listeners config:



render : function(){
this.form.items.each(function(i){
if(i.allowBlank == false){
i.fieldLabel = '<span style="color:red;">*</span>'+ i.fieldLabel;
}
});
}

moegal
25 Jun 2009, 9:57 AM
Is there a way to force the form to act is if each field was give focus already? The field will then have a new border color based on the theme.

Thanks, Marty