Max_nl
29 Jun 2009, 5:30 PM
Hi,
I am new to ext.js and am experimenting with form submits in combination with the Ext.Direct PHP stack.
In another thread (http://extjs.com/forum/showthread.php?t=71339) it is suggested to use the api property of the form for that.
So I created a setup among the lines of:
Ext.Direct.addProvider(Ext.app.REMOTING_API);
var form = new Ext.form.FormPanel({
api: {
submit: MyClass.submit
},
[...other form stuff...]
buttons: [{
text: 'Submit',
handler:function(){
form.getForm().submit();
}
And on the server I created a simple class like:
class MyClass {
/**
* @remotable
* @formHandler
*/
function submit($fields, $files)
{
[ .... code that inserts the information from the $fields array to the database ....]
}
}
While this seems to work, it is not clear to me what my submit( ) function should do in case an error occurs on the server, or if something is wrong with the data the user entered.
If I simply throw a PHP exception, it results in a javascript error on the browser:
Error: result is undefined
Source File: http://[ip]/ext/ext-all-debug.js
Line: 35527
So apparently that is not the way to go.
Do I have to "return" something instead to indicate an error to the client?
I am new to ext.js and am experimenting with form submits in combination with the Ext.Direct PHP stack.
In another thread (http://extjs.com/forum/showthread.php?t=71339) it is suggested to use the api property of the form for that.
So I created a setup among the lines of:
Ext.Direct.addProvider(Ext.app.REMOTING_API);
var form = new Ext.form.FormPanel({
api: {
submit: MyClass.submit
},
[...other form stuff...]
buttons: [{
text: 'Submit',
handler:function(){
form.getForm().submit();
}
And on the server I created a simple class like:
class MyClass {
/**
* @remotable
* @formHandler
*/
function submit($fields, $files)
{
[ .... code that inserts the information from the $fields array to the database ....]
}
}
While this seems to work, it is not clear to me what my submit( ) function should do in case an error occurs on the server, or if something is wrong with the data the user entered.
If I simply throw a PHP exception, it results in a javascript error on the browser:
Error: result is undefined
Source File: http://[ip]/ext/ext-all-debug.js
Line: 35527
So apparently that is not the way to go.
Do I have to "return" something instead to indicate an error to the client?