-
2 Mar 2011 6:02 AM #1
EXTJS 4.0 Model and remote validation?
EXTJS 4.0 Model and remote validation?
How would I go about using the new EXTJS 4.0 model with remote business rules?
For example let's say I am registering a user and we need to see if the user name / user id is not a duplicate. Client side validation in the model won't work in this case, we have to go to the web server.
I was looking through the API docs, maybe I missed something? What I want to see is if that user name / user id is invalid to go to the server and find that out, then flag the field with the red validation halo, like client side validation errors.
I know I can submit the whole model to the web server and then let my server throw an error of some nature, and then maybe have a pop-up alerting the user. But I think as a user there should be no UI difference between a client and server side client validation error.
Does anyone have a code snippet to share on how to go about this?
-
2 Mar 2011 7:07 AM #2
Hi,
Suppose you could override the fields validate method, then call to the server in there, setting the field as invalid when you get the response.
I believe validate is meant to return true or false though, so is not meant to be asynchronous.
Not quite sure how you're meant to set it's valid state, perhaps through getErrors()?
Edit: Oh, that was the field specifically I was looking at.
The model's validate returns the errors, so you would probably have to stall it's return somehow :/
-
2 Mar 2011 3:03 PM #3
Hmmm maybe a custom validate function.... Yeah...
Does anyone have an example? I know I am not the only one that needs this...
Maybe a Extjs developer could chime in? I can create custom logic like the previous poster is saying. But I would of expected this to be part of the framework
I just want to make sure that I am not missing something in the documentation since this is pre-release stuff... Or, you know, preview 3 will have it. If that's the case I don't want to "spin my wheels" coming up with something on my own.
-
3 Mar 2011 8:26 AM #4
As of now, I can't even validate on the server side unless I throw in HTTP Status Code.
The output of my server is
But when I executeCode:{"errors":{"name":"invalid name"},"success":false,"msg":"my message"}
It still calls "success"..and operations think it's a "success" as well. Help, plz??Code:newUser.save( { success : function(user, operations) { console.log(operations.success); } });
-
4 May 2011 4:21 AM #5
I'm experiencing same issue. Would anyone explain us, how to do remote model validations proper way, please ? Thanks.
-
14 Jun 2011 3:41 AM #6
I'm using 4.0.2 and it's working for me, if I return success:false, it calls the failure callback.
But my problem is that it doesn't seem to be doing anything with the errors I pass back... Is there any way for the model to be aware of server side errors or it's just possible in the forms??
-
11 Jul 2011 7:52 AM #7
What about plugin
-
11 Jul 2011 8:50 AM #8
mmmm, it's a nice plugin, but I thought since there's a validation in our new Ext models, why not be able to retrieve validation errors from the server? Besides it should be almost the same that we already have for forms...
-
28 Sep 2011 10:50 AM #9
-
29 Sep 2011 2:03 AM #10
Similar Threads
-
TextField with remote validation
By Caolga in forum Community DiscussionReplies: 25Last Post: 14 Sep 2012, 7:36 AM -
Ext.ux.MvcFormValidator - MVC 2 Client Side Model Validation with ExtJS
By tdupont in forum Ext 3.x: User Extensions and PluginsReplies: 1Last Post: 1 Mar 2011, 9:22 AM -
Model Validation
By ksystems in forum Sencha Touch 1.x: DiscussionReplies: 3Last Post: 15 Jul 2010, 7:41 AM -
remote validation
By ibcravi in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 3 Sep 2009, 10:53 AM


Reply With Quote
