View Full Version : Got stuck with FormPanel - form.load() - beg your pardon!

29 Jan 2008, 8:38 AM
Hello Guys,

giving up, have been reading a lot of forum posts today and could not find a solution. Can someone please help me run below code sucesfully?

The form renders in <div> tag as expecting but with empty fields.

My JSON response on the server is:
[{"bankname":"Rabobank (NL)","address":"some address"}]

The .js scripts:


Ext.form.Field.prototype.msgTarget = 'side';

var bankDetailsForm = new Ext.FormPanel({
applyTo: 'bank',
labelWidth: 100,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 210},
defaultType: 'textfield',

items: [{
fieldLabel: 'Bank Name',
name: 'bankname',
fieldLabel: 'Bank Address',
name: 'address'

buttons: [{
text: 'Save'
text: 'Cancel'

What I am doing wrong?


29 Jan 2008, 9:32 AM
Also, if this can help, below is attached the screen from the Firebug which shows weird error message.
In IE6 there are no js errors but form fields are still with no values.
Can someone get me out from the Dark, please?

29 Jan 2008, 12:33 PM
UPDATE: the Firebug error seemed to be caused by FF cache - after clearing the cache and restarting the pc no more Firebug errors.

But main problem still unresolved. I can not load JSON data to the form fields.
I have read that form.load() must be done after formPanel is rendered, so I even commented 'applyTo' parameter and put load command at the bottom of the script - no progress, fields still empty.


This is very annoying, I am really pissed of on myself - can not make any step forward!
Pls help desperate extjs newbie!

29 Jan 2008, 1:42 PM
You can only load data in a form if the form has a reader that can process the server response.

29 Jan 2008, 2:07 PM
Condor, many thanks for your time!

Digging on forum all-day-long and many times I have read that when comparing BasicForm and FormPanel - this 2nd doesn't require to set up the Reader as long as json structure and form's fields match each other. (?)

Will try to go to the light now, thanks!

29 Jan 2008, 2:10 PM
Dig your way down to the Ext.Form.Action.Load documentation.

Your JSON data needs to look like:

success: true,
data: {
clientName: "Fred. Olsen Lines",
portOfLoading: "FXT",
portOfDischarge: "OSL"

29 Jan 2008, 2:37 PM
Cerad, you're awesome!

I've changed the json format as you mentioned and form has been loaded with the data!

Now heavy question: guys, please advise which way shall I code further? Condor says "use reader", Cerad "change json format and load without reader". What I ask is what is the best way if we are saying I will be coding form submit and putting all wistles and bells in the GUI etc. ?

Again, thanks for your great support!

29 Jan 2008, 3:25 PM
Well any way you do it, you want correct JSON format.. which is


Can't have quotes around name...

29 Jan 2008, 9:55 PM
Well, in fact you can and you should:
http://simonwillison.net/2006/Oct/11/json/ -> keep your JSON valid. ;)

30 Jan 2008, 12:38 AM
I posted a bunch of code on making a CRUD form here http://extjs.com/forum/showthread.php?t=24550

It may help you