SQLFORM appears to not correctly display the value of an updated
boolean field after submission. Text fields correctly show updated
values.
In the toy application below, if you edit a dog record and update one
of the boolean fields, you will find it unchanged after a submit. If
you edit the text field and submit the form, you will find the text
field changed.
The problem goes away if you add a redirect after the
form.accept(...), like this:
redirect(URL('edit', args=request.args(0)))
Here is the application. If anyone finds something that would cause
this behavior, please let me know.
Thanks,
Cliff Kachinske
db.define_table('dogs',
Field('name', length=24),
Field('has_fleas', 'boolean', default=False),
Field('barks', 'boolean', default=True),def index():
links = ([lambda row : A('edit', _href=URL('edit', args=row.id))])
form = SQLFORM.grid(db.dogs, editable=False, deletable=False,
details=False, links=links)
return dict(form=form)
def edit():
form = SQLFORM(db.dogs, request.args(0))
if form.accepts(request, session):
response.flash = 'Doggie updated'
elif form.errors:
response.flash = 'Fix it'
else:
response.flash = 'Update the dog'
return dict(form=form)
{{extend 'layout.html'}}
{{=A('back', _href=URL('index'))}}
{{=form}}
)