I assume you are using a custom form in the view. web2py expects those fields that are in the form. web2py does not know that the field value is not present because you chose not to display it.
Before form = SQLFORM(db.user, session.currentUserID) you should do db.user.company_id.writable=False so that web2py knows it should not go in the form. Mind that this using the session to store the id of the record you are editing as in form = SQLFORM(db.user, session.currentUserID) breaks if the user has two windows open and tries to edit two records. I would go with: form = SQLFORM(db.user, request.args(0)) On Feb 18, 5:49 pm, waTR <r...@devshell.org> wrote: > I have created a form using SQLForm. I am using a db query to select a > single row from a db table, and I want to make changes to it. However, > when I submit, some of the data disapears in the submit. This happens > to also prevent the form from submitting as that data that disapears > is very important. > > Here is what I have: > > DB table "company" with fields name and title > DB table "user" with fields name and title, and a foreign key of > company id > > When I use SQLForm(db.user, session.currentUserID) and submit this > form, the company_id field is null, even though before I submitted the > field in the DB has a 2 in it. Note that I have not actually > generated the field in a view. So I imagine that any field that is not > in the view is submitted as NULL. Is this a bug? I believe any field > that you don't use in a view should just be re-submitted with the same > data that was in the field before. Whats going on here? Why does the > field go empty? > > Is there a way to manually set a value to the field before it submits? -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.