I'd been thinking I needed to do that between form creation and the
accepts call, but you're right, it works even after that point.  I
make the call to auth.register, and then modify the readonly
attribute, and it works fine.

Thanks!
Jay

On Thu, Jun 16, 2011 at 5:06 PM, DenesL <[email protected]> wrote:
>
> Jay, you can do:
>
> form.element('#tablename_fieldname')['_readonly']=True
>
>
> On Jun 16, 2:57 pm, Jay Shaffstall <[email protected]> wrote:
>> That doesn't seem to affect the HTML form output at all for me.  I've
>> also tried changing the widget to LABEL, but that results in the same
>> problem with the value not being transmitted back via the form.
>>
>> 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
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Jun 16, 2011 at 2:21 PM, Bruno Rocha <[email protected]> wrote:
>>
>> > Sorry, I answered before read entire message,
>> > if you want to chamhe it in form only, better to use the 'represent'
>> > attribute
>> > db.table.field.represent = lambda f: "<label> %s </label>" % f
>>
>> > --
>> > Bruno Rocha
>> > [ About me: http://zerp.ly/rochacbruno ]
>>
>> > On Thu, Jun 16, 2011 at 3:05 PM, Jay Shaffstall <[email protected]>
>> > wrote:
>>
>> >> 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.
>>
>> >> 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

Reply via email to