Harry, What's going on is that the instance of your model class that's being validated is different from the instance of the model class that's used to render your form.
There are two ways to deal with this: RequestVars and StatefulSnippets. For RequestVars: object MyThing extends RequestVar(Thing.create) class MySnippet { def render(xhtml: NodeSeq): NodeSeq = { val thing = MyThing.is bind("info", xhtml, "name" -> SHtml.hidden(() => MyThing.set(thing)) ++ thing.name.toForm) } } For stateful snippets: class MySnippet extends StatefulSnippet { val thing = Thing.create def dispatch = { case _ => render _ } def render(xhtml: NodeSeq): NodeSeq = { bind("info", xhtml, "name" -> thing.name.toForm) } } THanks, David On Tue, Aug 25, 2009 at 12:03 PM, harryh <har...@gmail.com> wrote: > > Let's say I have something like so: > > object name extends MappedString(this, 50) { > override def validations = valMinLen(5, "name must be at least 5 > characters") _ :: super.validations > } > > I can now easily use myObject.name.toForm to generate an <input> > elements and deal with the results. But let's say the user enters > "Bob" for their name so it doesn't validate (and they get an > appropriate error message). When this happens, the field resets back > to the original value. What I'd really like to do is keep the user > entered value with the expectation that the user would change it > before re-submitting. > > The same is true for all of the other fields on the form. When there > is an error in one of them, they all reset back to the orignal state. > (so an error in 1 field means the user has to re enter the data in all > fields). Is there a trivial way to fix this? Planning to dive into > the sourcecode if there isn't, but what I want kind of seems like what > should maybe be default behavior for MappedFoo objects. > > -harryh > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---