Yes that works, though it's not as secure because someone can still submit
a value for that field if they are determined, so you might want to check
for that variable on the server and delete it if submitted.
Anthony
On Tuesday, June 25, 2013 12:15:04 AM UTC-4, Tom Russell wrote:
>
> I ended up doing this in the controller which works for what I need:
>
> form.element('#no_table_medical_record_number')['_readonly']=True
>
>
> On Tue, Jun 25, 2013 at 12:03 AM, Anthony <[email protected] <javascript:>
> > wrote:
>
>> I'm not sure that method will work for readonly fields, so you may have
>> to use the method I showed (i.e., set the default value for the field
>> before creating the form).
>>
>> Anthony
>>
>>
>> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>>
>>> Yes I tried that:
>>>
>>> Field('medical_record_number', label='MRN', writable=False,
>>> readable=True, requires=IS_NOT_EMPTY()),
>>>
>>> Still just shows none for the field on the form.
>>>
>>> In my controller this is what I am doing:
>>>
>>> form.vars.medical_record_**number = 'KND' + str(date.today().year) +
>>> '0000' + str(random.randrange(1, 9999999+1))
>>>
>>> If I set both to True then it shows the value no problem.
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>>
>>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony <[email protected]> wrote:
>>>
>>>> db.mytable.myfield.default = some_value
>>>> db.mytable.myfield.writable = False
>>>>
>>>> Leave readable at True in order to show the value but not allow it to
>>>> be edited.
>>>>
>>>> Anthony
>>>>
>>>>
>>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>>
>>>>> I have a form and I load a pre existing value that I generate
>>>>> internally before I call the form. What I want to see on the form is the
>>>>> value shown up but just as plain text so the user cannot modify it. If I
>>>>> do
>>>>> readable-False then it just shows None for the value rather than the
>>>>> value.
>>>>>
>>>>> How would I make that happen on the form then?
>>>>>
>>>>> Thanks.
>>>>>
>>>> --
>>>>
>>>> ---
>>>> 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+un...@**googlegroups.com.
>>>>
>>>> For more options, visit
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>>
>>>>
>>>
>>> --
>>
>> ---
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.