View Full Version : getForm() in keyup event returns undefined

24 Mar 2014, 8:43 AM
I wonder if anyone can help me with the following issue:

I have a textfield in a formPanel, which is in turn in a tabPanel. When user types in this textfield, I want to its value displayed in another dislayfield. It works fine if I use id for both fields. But using id will prevent creating multiple instances of the formPanel object. Therefore I need to use field name instead. When I use the field name, I cannot use Ext,getCmp(), I use this.form.getForm().findField(). Then I get error-- this.form undefined. Does anybody know how to get around it? Many thanks in advance.


25 Mar 2014, 2:41 AM
Just get this sorted. I missed bind(this) at the end of the fn. The entire listeners should be like this:
listeners: {
'keyup': {
fn: function(field, key) {
var value =this.form.getForm().findField('title').getValue();
this.form.getForm().findField('token').setValue(Ext.util.Format.lowercase(value.replace(/ /g , '-')));

Gary Schlosberg
25 Mar 2014, 7:38 AM
Glad to hear you got it working, and thanks for taking the time to post a follow-up with code.