Is there a way to set an SQLFORM field so that it appears as a label
on the form itself, but is still writable for the database?
For reference, I'm doing this with a field in the form returned by
auth.register, so I cannot insert code between the form creation and
the accepts call. I believe I'm restricted to working with the model
before calling auth.register, or by using custom forms.
Jay
What I'd like to be able to do is set the readonly attribute of the
input tag; but I don't know how to do that in this context, where I
cannot insert code between the creation on the SQLFORM and the accepts
call.
Jay
I have a situation where I need to adjust an SQLFORM field to be
non-editable. I can do that with .writable = False, but that seems to
also prevents database I/O for that field. What I'm trying to do is
set a default that cannot be changed.
For reference, I'm doing this with a field in the form returned by
auth.register, so I cannot insert code between the form creation and
the accepts call. I believe I'm restricted to working with the model
before calling auth.register, or by using custom forms.
Thanks!
Jay
Can you elaborate?
--
I understand the proposed procedure is as follows:1. change db table field to writable2. make the form as needed3. change back db table field to not writable
I understand the proposed procedure is as follows:1. change db table field to writable2. make the form as needed3. change back db table field to not writableFirst, I don't think this is the proposal. The proposal was to manipulate the form object itself after the form is created, but before it is serialized in the view (i.e., set the HTML "readonly" attribute of the input widget).
Second, even something like the above wouldn't be a problem for concurrent users, as the above would all happen within a single request and therefore only apply to that one request. Setting a field to writable in one request does not affect it another request.
Sorry, I was referring todb.table.field.writable = False # change the field to writable falseSecond, even something like the above wouldn't be a problem for concurrent users, as the above would all happen within a single request and therefore only apply to that one request. Setting a field to writable in one request does not affect it another request.I am not sure if I understand this for db.table.field.writable. The change is occurring within the shared DAL object. Is it not?
Sorry, I was referring todb.table.field.writable = False # change the field to writable falseSecond, even something like the above wouldn't be a problem for concurrent users, as the above would all happen within a single request and therefore only apply to that one request. Setting a field to writable in one request does not affect it another request.I am not sure if I understand this for db.table.field.writable. The change is occurring within the shared DAL object. Is it not?
No, the DAL object is not shared. Each request happens in a new thread, and all the objects generated in the app code are specific to that request and thread. The database itself is shared and accessible from multiple requests, but the web2py objects defined in the app code are not. If the writable attribute of a field is set in one request, that does not affect its status in another request.