I tried the lines in my previous post and they worked. Perhaps you'd like to provide minimal code to reproduce your problem.
When talking about the redefining, yes, it is an unusual way and somewhat hard to be understood at the beginning, but it is how web2py does things. Just be aware that your model definition are indeed recalculated in each web request (yet still fast enough). Same applies to your controller, so you can even have two different functions in your controller, each defines different default value, different readable or writable combinations, etc. When you get used to it, you find a brand new world. :-) Iceberg On Sep17, 2:18pm, Alastair Medford <[email protected]> wrote: > No dice. Neither of the two lines had any effect (this is with them in > the controller). The field was blank and was still writable. Also, if > this approach worked, or if I changed the default value in the model, > wouldn't this be redefining the table definition every time the form > is brought up? If so, this doesn't seem like a desirable approach. > Would this be the case? > > On Sep 16, 11:33 pm, Iceberg <[email protected]> wrote: > > > > > Try: > > > db.table.time.default=getCurrentTime() > > db.table.time.writable=False > > form = SQLFORM(db.table) > > if form.accepts(...) > > > On Sep17, 12:33pm, Alastair Medford <[email protected]> wrote: > > > > What I'm trying to do is preset the value of a non writable field in a > > > form, such as a time field. Something to the effect of: > > > > form = SQLFORM(db.table) > > > form.vars.time = getCurrentTime() #this field is set to writable false > > > if form.accepts(...): > > > ... > > > > The desired rendering would be that the field cannot be edited, but > > > displays the current time, and will be entered into the database once > > > the form submits. But I've noticed that web2py ignores the .vars > > > setting and instead puts in the database given default value. I'm not > > > sure if this was always the case, as I seem to remember having this > > > work as expected before. Is there any way to get my desired rendering? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

