On Dec 5, 2006, at 9:40 PM, thesamet wrote:
> > Thanks for your answer. > > Some fields in my form have a validator which requires them to be > non-empty. In that case, these errors appear on the first time the > form > is displayed. Default values are lost as well - the form thinks the > user entered wrong values already. Hmmm, this is normal because the same controller method showing the form is also validating it (with the decorator), therefore when called with no request params required fields fail validation and the form thinks it's being redisplayed so it prints errors and input values (all blank). I can think of three ways to circumventing it: 1) separate your form showing and handling methods in two. 2) keep a hidden field in your form with a StringBoolean validator initialized like StringBoolean(if_empty=False) which defaults to true. Then check for it being True in FormValidator for the whole form. 3) Subclass Form and extend it's "validate" method so it only filters the value through the validator if the request method is a POST. I'd personally go with 1 as it's easiest. If your app can't afford it (due to requirement constraints, for example) then I'd try 3. HTH, Alberto --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

