Does removing writable=False in your extra_fields help? It you set this to
false it means the field is neither readable or writable it you want it to
be include in the form put it to writable=True so form will include the
field... I am not sure what you try to achieve with session variable, but
you may consider using the default or update field attributes to set
"default" profile_type depending of the context of your form...

You can set this in the controller of you form like so :

db.auth_user.profile_type.default = PROFILE_TYPE_YOU_PREFER

default is for create form and update is in context of an record update
obviously...

Richard

On Fri, Nov 24, 2017 at 10:09 AM, Fabio Ceccarani <[email protected]
> wrote:

> Hi all,
> I have a double registration form (one in controller, two in view):
>
>
> IN DB.PY
> auth.settings.extra_fields['auth_user']= [
>    Field('profile_type', readable=False, writable=False, label='Profile
> type', requires=IS_IN_SET({1:'Person',2:'Organization'})),
> ...
> ]
>
>
>
> IN USER.HTML
>
> ...
> <div>
> <h1>profile type1</h1>
> ....
> {{session.profile_type = 1}}
> {{=form}}
>
> </div>
> ...
> <div>
> <h1>profile type2</h1>
> {{session.profile_type = 2}}
> {{=form}}
> </div>
> ...
>
>
>
> IN DEFAULT.PY
>
> def user():
> ...
> return dict(form=auth())
>
>
> How can I write the field auth_user.profile_type = session.profile_type
> from controller?
> I tried in 100 way, but nothing!
>
> Thanks!
> Fabio
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to