PDA

View Full Version : Forms and some issues



ksachdeva
6 Jul 2007, 10:01 AM
Here are some of the issues I have been facing:

a) I would like to use a TextField which is not inside a Form but require client side validation. I am able to create an instance of Ext.form.TextField and use it but the validation messages are displayed as tool tip (i.e. you have to hover the Textfield to see the error). I tried to set Ext.form.Field.prototype.msgTarget = 'under'; but this makes ExtJS throw an error in markInvalid function at

case 'under':
if(!this.errorEl){
var elp = this.el.findParent('.x-form-element', 5, true);
this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
this.errorEl.setWidth(elp.getWidth(true)-20);
}
this.errorEl.update(msg);
Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this);
break;

Since I have not put TextField in any form it is obvious that elp will be null and that's why it throws an error at elp.createChild....

b) Putting TextField inside a form so that I can get the error message under the text field but some more issues for me here:
- I do not want to display the ":" between the label and inputbox as I do not want to put the label. Is there a work around ?
- I would like this form to anchor in a content panel with "c-c". But I could not invoke anchor method on form. I could not find how to get the dom element of form so I could anchor that in my panel.

In brief, I would like to have an input box with client side validation where messages are displayed under the input box. This input box should be anchored in a content panel with "c-c".

Would appreciate your help.

Regards & thanks
Kapil

ksachdeva
9 Jul 2007, 11:50 AM
Would appreciate if some one could help me out.

Regards
Kapil

tryanDLS
10 Jul 2007, 7:29 AM
a) Look at what the code is doing - it looks for a container with a class of x-form-element. If you're not building a Form object you need to put your field in a div with that class.

b1) This has been covered many times - labelSeparator:''
b2) Shouldn't you be trying to anchor the same container that your called render with?

ksachdeva
11 Jul 2007, 9:06 AM
Thanks Tim, you suggestions really helped me out.