Hi, I have been working with an issue for a few hours, and can see what is happening, but I would like to better understand why this happens. Although I have a solution, some information or help as to why this is happening would be very useful. I would be sure that the answer is simple and probably obvious..
I have a complex table, where I want to expose just some of the fields in a custom form, and am using SQLFORM with a custom form. The symptom I see is that the fields that I am NOT exposing in the view and custom form are also being updated. Booleans are being set to False; datetime set to None etc. Because I am updating some fields in a existing record. I had assumed that the other fields in that record would be retained as they were (i.e. not updated) I can define the fields=[...] parameter in SQLFORM and that appears to work. But, the tables and views I am working with are complex make it onerous to write and maintain. It doesn't seem to matter if there are default field values or not. What I would like to understand is: Is there a simple method to use a custom form to expose only some of the fields in a record - but that does not also update the non-exposed fields. Here is a sample app to demonstrate the problem. MODEL import datetime db.define_table('mytest', Field('myname','string',length=10,default=''), Field('myflag','boolean',default=False), Field('mydate','datetime',default=datetime.datetime.today())) db.define_table('mytest2', Field('myname','string',length=10,default=''), Field('myflag','boolean'), Field('mydate','datetime')) CONTROLLER def form_1(): form=SQLFORM(db.mytest,record=1) #or use db.mytest2 And use a record number for a known record if form.process().accepted: response.flash='Updated' return dict(form=form) VIEW {{extend 'layout.html'}} <h1>form_1 view</h1> {{=form.custom.begin}} ID: {{=form.custom.widget.id}}<br /><br /> MyName: {{=form.custom.widget.myname}}<br /><br /> {{=form.custom.submit}}<br /> {{=form.custom.end}} You can see that the custom form exposes only the id and myname fields. Yet the myflag and mydate fields are being blanked (in the database) when the form is submitted. As I say, I can use the fields=[...] in SQLFORM, but because of the complexity of the real code, I would rather not have to maintain that. I am using 2.3.2. and SQLITE. Thanks for any guidance. -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.