I am trying to use a "m/d/yyyy" format for a date field.  I've also
created a custom widget for the field.  Everything seems to be working
fine except when a form is submitted with validation errors.  The
returned form value for the date reverts back to "yyyy-dd-mm", even
when the form was submitted with a date value in 'm/d/yyyy' format and
the validation error was caused by another field. Perhaps I'm doing
something wrong.  However I was able to fix the problem by adding two
lines to sqlhtml.py.

It seems that this line (942):
>>   widget = field.widget(field, value)
would return my custom widget markup with an input value with correct
date format
but line 944:
>>   self.field_parent[row_id]._traverse(False,hideerror)
would change the input's value to a date format of 'yyyy-dd-mm'

The lines I added to fix this became 944 and 945:
>>   if field.represent and self.field_parent[row_id].vars.get(field.name, 
>> False):
>>      self.field_parent[row_id].vars[field.name] = 
>> field.represent(self.field_parent[row_id].vars[field.name])

I don't really want to fork this so if I could get some feedback as to
what I may be doing wrong or whether this fix are something equivalent
will make it into the trunk, that would be greatly appreciated.

FYI, I've got a week's experience in web2py and python so take it easy
on me :)

Reply via email to