and I can check why form.vars doesn't work. I suspect you're right though: form.vars "happens" after the call to the validator formatter, that is the one "translating" the date format.
On Saturday, September 21, 2013 1:52:52 AM UTC+2, Joe Barnhart wrote: > > You are a wizard Mr. Niphlod. Using "default" does indeed work where > presetting the form.vars does not. > > I now have a path that works so I am a happy camper! > > -- Joe B. > > On Friday, September 20, 2013 11:57:24 AM UTC-7, Niphlod wrote: >> >> what if you edit a pre-existing record or if you set a default value >> using db.table.field.default instead of form.vars.field ? >> >> On Friday, September 20, 2013 7:23:47 PM UTC+2, Joe Barnhart wrote: >>> >>> Hi Niphlod -- >>> >>> This is what I thought as well. Yet in my controller I have set this: >>> >>> >>> >>> dbrw.birth.requires=[IS_DATE_IN_RANGE(maximum=target,format="%m-%d-%Y")] >>> >>> >>> Still, I do not get the format mm-dd-yyyy but rather yyyy-mm-dd when the >>> form is displayed. I have tried it with and without the enclosing list >>> and, although it will correctly read back the format I specified, it always >>> displays the form initially with the wrong date format. >>> >>> Here is something I just discovered that is clearly related to my >>> problem... I am presetting values in the form vars after creating the form >>> but before displaying it. >>> >>> if presets: >>> form.vars.update(**presets) >>> >>> The birth date is one of the values in the preset. The birth date is, >>> at that moment, a Python date object and is assigned to the form.vars.birth >>> variable before calling the view. Somehow I think this is causing the code >>> to bypass the formatter part of the IS_DATE_IN_RANGE widget. >>> >>> If I do not preset the field, of course, there is no incorrectly >>> formatted date in the form -- there is no date at all. >>> >>> -- Joe >>> >>> On Friday, September 20, 2013 4:11:38 AM UTC-7, Niphlod wrote: >>>> >>>> >>>> BTW, a simple requires=IS_DATE(format='%d-%m%-%Y') works, given that no >>>> '%d-%m-%Y' is never translated. >>>> >>>>> >>>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

