[BUG] solution for form.custom.widget and custom widget

12 views
Skip to first unread message

ont.rif

unread,
Jun 14, 2010, 10:38:50 AM6/14/10
to web2py-users
For complex widgets there is bug.
During form validation "_traverse" method doesn't change
form.custom.widget. But field.widget(field, value) return correct
representation.
This is lead to wrong field widget output for custom form and custom
widget when error occurred.
Solution is simple:

--- sqlhtml.py
+++ sqlhtml.py
@@ -909,8 +909,10 @@
if hasattr(field, 'widget') and field.widget\
and fieldname in request_vars:
row_id = '%s_%s%s' %
(self.table,fieldname,SQLFORM.ID_ROW_SUFFIX)
- self.field_parent[row_id].components =
[field.widget(field, value)]
+ widget = field.widget(field, value)
+ self.field_parent[row_id].components = [ widget ]
self.field_parent[row_id]._traverse(False)
+ self.custom.widget[ fieldname ] = widget ##
also update widget for custom form creation
return ret

if record_id and record_id != self.record_id:
Reply all
Reply to author
Forward
0 new messages