I think you can't have your computed field to display in the form... I mean
it makes no sens anyway, since the user should not be allow to enter a
value in this field since it a calculated field.

I am not sure about the behavior of readable and writable field in case of
computed field in a form and why it should prevent the field to compute in
case you set to writable=False. For sure combination of both field
parameter (readable and writable) on Update, Read and Select should works
as describe in the book :

readable if a field is readable, it will be visible in readonly forms. If a
field is neither readable nor writable, it will not be displayed in create
and update forms.

writable if a field is writable, it can be edited in autogenerated create
and update forms.


Anyway, when I use computed field, in the create form, I just leave the
default web2py behavior, I mean, the field is not there. By default, it
should be there in the read version of the form and not there in the update
version of the form. And it should be there in the select.

If this is not good for you, you may try different combination of readable
and writable, true or false, at the same time to see if you can set the
proper behavior you are searching for. Or you may just give up if you can't
get it and explain your users...

Hope it help.

Richard

On Wed, Apr 18, 2012 at 12:51 PM, simon <[email protected]> wrote:

> I have a person table with date of birth and a compute field for age. I
> want my form to show date of birth (writable) and age (read only). When the
> form is accepted I reread the table and create a new SQLFORM with the new
> age.
>
> However I cannot get this to work.
>
>    - On a SQLFORM the age does not show up by default even if
>    readable=True.
>    - If I include age in the "fields" parameter and writable=True then it
>    shows up but is editable.
>    - If I set writable=False then it does not recalculate the computed
>    field.
>
> Wouldn't it be better for computed fields to show up if readable=True;
>  and to be updated even if writable=False?
>
>
>
>
>

Reply via email to