raphinou
4 May 2007, 12:32 AM
Hi,
I'm using the yui-adapter, trying to load xml data in a form. I'm following the example at http://extjs.com/deploy/ext/examples/form/xml-form.html .
The request is sent to the server and the xml is retrieved, but the form fields aren't filled. I'm first defining a UserRecord, with all fields in the xml being mapped. I then define a XmlReader, which reads UserRecords. And I use this reader in the form. I've removed baseParams as I read this could be problematic (http://extjs.com/forum/showthread.php?t=5032&highlight=Form+load).
But the form fields don't get filled, and I don't get any error in firebug.
I put the code below in the hope someone can help me as I don't see what I'm doing wrong. thanks in advance.
UserRecord = Ext.data.Record.create([
{ name: 'id'},
{ name: 'name'},
{ name: 'firstname'},
{ name: 'birthday', type:'date', format: 'Y-m-d'},
{ name: 'street'},
{ name: 'zip_code', mapping: "zip-code"},
{ name: 'city'},
{ name: 'email'},
{ name: 'login'},
{ name: 'identity_url', mapping: "identity-url"},
{ name: 'country'}
]);
user_reader= new Ext.data.XmlReader({
record: 'user',
id: 'id'
},
UserRecord
);
user_form = new Ext.form.Form({
labelWidth: 100,
url:'/user/9.xml',
method: 'get',
reader: user_reader
});
user_form.add(new Ext.form.TextField({
fieldLabel: "First name",
name: "firstname"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Name",
name: "name"
}));
user_form.add(new Ext.form.DateField({
fieldLabel: "Birthday",
name: "birthday"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Street",
name: "street"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Zip code",
name: "zip_code"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "City",
name: "city"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Country",
name: "country"
}));
user_form.render("user_form");
user_form.load( );
and the xml loaded is:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<user>
<birthday type="date">1975-01-01</birthday>
<city>Brussels</city>
<country>Belgium</country>
<email>myemail@example.com</email>
<firstname>Rapha
I'm using the yui-adapter, trying to load xml data in a form. I'm following the example at http://extjs.com/deploy/ext/examples/form/xml-form.html .
The request is sent to the server and the xml is retrieved, but the form fields aren't filled. I'm first defining a UserRecord, with all fields in the xml being mapped. I then define a XmlReader, which reads UserRecords. And I use this reader in the form. I've removed baseParams as I read this could be problematic (http://extjs.com/forum/showthread.php?t=5032&highlight=Form+load).
But the form fields don't get filled, and I don't get any error in firebug.
I put the code below in the hope someone can help me as I don't see what I'm doing wrong. thanks in advance.
UserRecord = Ext.data.Record.create([
{ name: 'id'},
{ name: 'name'},
{ name: 'firstname'},
{ name: 'birthday', type:'date', format: 'Y-m-d'},
{ name: 'street'},
{ name: 'zip_code', mapping: "zip-code"},
{ name: 'city'},
{ name: 'email'},
{ name: 'login'},
{ name: 'identity_url', mapping: "identity-url"},
{ name: 'country'}
]);
user_reader= new Ext.data.XmlReader({
record: 'user',
id: 'id'
},
UserRecord
);
user_form = new Ext.form.Form({
labelWidth: 100,
url:'/user/9.xml',
method: 'get',
reader: user_reader
});
user_form.add(new Ext.form.TextField({
fieldLabel: "First name",
name: "firstname"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Name",
name: "name"
}));
user_form.add(new Ext.form.DateField({
fieldLabel: "Birthday",
name: "birthday"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Street",
name: "street"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Zip code",
name: "zip_code"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "City",
name: "city"
}));
user_form.add(new Ext.form.TextField({
fieldLabel: "Country",
name: "country"
}));
user_form.render("user_form");
user_form.load( );
and the xml loaded is:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<user>
<birthday type="date">1975-01-01</birthday>
<city>Brussels</city>
<country>Belgium</country>
<email>myemail@example.com</email>
<firstname>Rapha