PDA

View Full Version : DirectLoad gives this.form.api.load is undefined error



dearsina
13 Feb 2010, 5:34 AM
I'm trying something seemingly simple here, just load a form using directload:



Ext.Direct.addProvider({
type : 'remoting',
url: 'api.php',
actions: {
profile: [{
name:"read",
len:0
},{
name:"update",
len:0,
formHandler:true
}]
}
});

var profile_form = new Ext.form.FormPanel({
anchor: '100%',
frame: true,
bodyStyle: 'padding:10px;',
defaults: {
labelSeparator: '',
labelStyle: 'font-family:Tahoma;font-size:11px;',
validationDelay: 1500,
anchor:'-18'
},
defaultType: 'textfield',
items: [{
id: "userID",
name: "userID",
hidden: true,
hideLabel: true
},{
fieldLabel: "$l[74]",
name: 'name',
disabled: true
},{
fieldLabel: "$l[6]",
name: 'email',
vtype: 'email'
}],
buttons: [{
id: 'profile_update_button',
text: "Save",
iconCls: 'icon_disk-black',
handler: function(){
profile_form.getForm().submit({
success: function(form,r){
profile_win.close();
}
});
}
}],
api: {
load: profile.read,
submit: profile.update
}
});
var profile_win = new Ext.Window({
id: 'profile_win',
title: "My profile",
iconCls: 'icon_user-white',
layout:'anchor',
width: 400,
border: false,
plain: true,
items: [profile_form]
});
profile_win.show();
profile_form.getForm().load();


The error I get is


this.form.api.load is undefined


What am I doing wrong? Thank you for your time!

cerad
13 Feb 2010, 7:56 AM
Check your syntax elsewhere in your code. I pasted what you posted directly inside of an onReady block and it seemed to work.

The 'this' in your error message is suspicious. Are you nesting everything inside of some other object?

dearsina
14 Feb 2010, 6:05 AM
Yeah, the whole thing is wrapped in a function that's called once a button is pressed, maybe that's where the error lies. I'll try to move some things around. Thanks for the suggestion!

dearsina
14 Feb 2010, 6:13 AM
Ok, I guess I walked into this one. The name of the function it was wrapped around was called "profile", the same name I gave to the Direct Action. It didn't like that. So when I renamed the Action, everything worked fine.