From: Alex B. <en...@tu...> - 2001-09-10 18:20:54
|
> Just an off the wall question regarding the FormBuilder and validation > classes. heh, cool. > Since there are many ways of validating user input and displaying any > errors, I was curious how FormBuilder will handle this. I've always > preferred the client side javascript checks. IE: if First Name is > blank, an alert explaining the error is sent onSubmit, then focus on > invalid field. The more popular way is too simply process the form, > collecting any errors and display them on a page, with a link back to > the form. Alot of times the link back to the form is a mere > javascript:history.back() which tends to lead to a "Data Missing from > POST operation error" requiring a reload. I guess my question is.. how > will this work? _binarycloud_ will provide 'server-side' means of processing and validating incoming data. So, for example: user had a form with: Name, Email, Address, City, State, Zip They enter some stuff: Mr. Foo, moo@foo (note the incorrect email), 123 Moo Lane, Berkeley, CA 94710 I don't have any plans for building JS (i.e. client-side) input vaildation, but I imagine that would actually be fairly easy to build if you already have the JS, and I'm happy to give you a flag in formbuilder that says "generate JS validation.. So assume server-side only: FormBuilder gets the data back (which is knows _nothing_ about) and passes it directly to EntityManager. EntityManager uses any Processors and Validators on the dataset to determine if it is O.K. or bad. If it's ok, EntityManager::Add() returns true, and FormBuilder presents the 'success' page (or however you have configured it) is presented. If EntityManager::Add() returns false, FormBuilder checks the Error stack (I'm undecided about this one: whether to register global errors in a stack which FormBuilder checks, or whether to "localize" the errors and keep them in context) anyway.. FormBuilder takes those errors and sends back the same form, but with all kinds of stuff in it, maybe: "Sorry, you are stupid, please have a look at the errors below" -> Your email address is not valid, please re-enter it. Name: Mr. Foo Red-> Email: moo@foo Address: 123 Moo Lane City: Berkeley State: CA Zip: 94710 ... The idea being that FormBuilder will _only_ be in the business of _building forms_ - Validation, etc will _always_ happen with EntityManager. --------- That's how I see it working. Re: JS: I think you'd probably just want to have a flag in the form Definition that says "Do JS validation on this one with some stock function" I'm sure that would be pretty easy to do. _a |