5 Oct 2009 10:27 PM #1
Get form field by name
got a form named 'MyForm' with textfield named 'NameField'
Which is best method to read textfiel value
Ext.get(''MyForm' ').fields.get('NameField').value which is not really working.
Ext.getDom(id) works if use 'id' instead of 'name'.
But 'id' is really required? can it work with 'name' alone.
Never used 'id' for form elements earlier. and values accessed by document.forms[''].elements[''] instead of document.getElementbyid('') which was expensive.
And 'id' used for div,span,table etc.
Is that the best practice to follow in extjs also considering UI with too many form fields and other html elements.
5 Oct 2009 10:54 PM #2
var value = Ext.get(''MyForm").getForm().findField("NameField").getValue(); or
var value = MyForm.getForm().findField("NameField").getValue(); // if MyForm is an valid ext Form object
6 Oct 2009 3:24 AM #3
One more query related to this.
normally forms can be accessed like document.forms also.
Is there a similar method in ext to get form without specifying name.
6 Oct 2009 4:03 AM #4
- Join Date
- Mar 2007
- The Netherlands
- Vote Rating
The first example one is wrong. It should be:
var value = Ext.getCmp(''MyForm").getForm().findField("NameField").getValue();
17 May 2012 3:59 AM #5
Nothing works to get particular field name from form. My condition is that, I have a form including some text field with same name like 'player' (array). Now I want to get each player field to validate.
Nothing is working.... please help to fixed it.
30 May 2012 5:43 AM #6
You can use find method of form's container to get all same named fields. First, you can get MyForm's container with getComponent method, then use find method.
MyForm.ownerCt.find('name','nameField');sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
27 Feb 2013 5:14 PM #7
Ext.getCmp(''MyForm").getForm() returnsObject [object Object] has no method 'getForm'is this 'MyForm' the form id?
28 Feb 2013 12:03 AM #8
25 Apr 2013 2:29 PM #9
May be wrong extend
If you get the error Object [object Object] has no method 'getForm' then you might have extended panel.Panel instead of form.Panel. Not 100% sure
extend: 'Ext.form.Panel', // it shudn't be extend: 'Ext.panel.Panel',