PDA

View Full Version : BasicForm not setting Items?



methodz
26 Nov 2007, 1:58 PM
Is there something explicitly wrong with the following code, or is the BasicForm not supposed to be able to load records into existing markup?



<script type="text/javascript" src="/js/Ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="/js/Ext/ext-all.js"></script>
<script>
Ext.onReady(function(){
testForm = new Ext.form.BasicForm('test');
testForm.render('test');
});
</script>
<form name="test" id="test">
<input type="text" name="name" />
</form>


When using the above code, and inspecting the object after the page renders, the items array is empty, which is why the loadRecord, setValues function(s) aren't working properly, is there some gross error in how I'm attempting to use BasicForm?

tryanDLS
26 Nov 2007, 2:11 PM
Kinda of hard to say without seeing more code. What does the json response look like? Did you call load and does firebug show the request going out and coming back?

methodz
26 Nov 2007, 2:24 PM
I can rule out JSON Being the problem, because all the XHR looks completely normal, try this in firebug, with that code example you should be able to run this in the console & have the field populate testForm.setValues({id:'name',value:'test'}); but that doesn't work...

tryanDLS
26 Nov 2007, 2:37 PM
I don't see how that could work - you have a field called name but you're calling setvalue with id and value.

You shouldn't be doing that directly anyway - calling load will populate the fields with the data you send back, assuming that you match the names correctly.

methodz
27 Nov 2007, 8:07 AM
I've dug all the way back into this code, and the load method invokes the same thing that setValues or loadRecord does, one problem is I'm trying to work with this with a single row result from a grid's datastore, but again, the use of the load method doesn't appear to be the problem, when the form is constructed, it doesn't set the internal items array properly, I've tried dropping the id value from every field and I still don't get that array...

methodz
27 Nov 2007, 8:59 AM
It appears unless I define each of the values in js and attach them to the elements in my basicForm, (Double the work) the basicform doesn't serve the purpose of an effective container.

gpasq
16 Mar 2008, 11:50 AM
Did you ever get this to work without also creating the fields in JS? I cannot either.


It appears unless I define each of the values in js and attach them to the elements in my basicForm, (Double the work) the basicform doesn't serve the purpose of an effective container.