PDA

View Full Version : BasicForm.getValues() returns undefined!



super_drone
9 Nov 2009, 12:05 PM
Hello List
Following is the simplest BasicForm but when getValues() is called on it, it returns 'undefined'. As you can see, it has one value.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='http://extjs.cachefly.net/ext-3.0.0/adapter/ext/ext-base.js'></script>
<script type='text/javascript' src='http://extjs.cachefly.net/ext-3.0.0/ext-all.js'></script>
<script type='text/javascript'>
function init() {
var f = new Ext.form.BasicForm('a-form');
f.add(new Ext.form.TextField({ name:'first_name', id:'first-name', allowBlank: false, value:"A NAME"}));
alert(f.getValues().first_name); //<-- Says undefined!
};
Ext.onReady(init);
</script>
</head>
<body>
<form id='a-form'>
</form>
</body>
</html>


What am I doing wrong?

Animal
9 Nov 2009, 12:49 PM
A BasicForm only handles submission of EXISTING DOM forms.

It's a FormPanel (or any Container) which handles the RENDERING of form fields into the DOM.

Start with some examples, there are plenty.

super_drone
9 Nov 2009, 1:41 PM
Ok. Another Ext Lesson learned the hard way.

If BasicForm is not able to handle dynamically created FormFields, it should throw an exception during 'add'. It's mighty confusing otherwise. It adds the field - only to ignore it later (:|