That can works too, but with more click... Good luck.
Richard On Mon, Nov 27, 2017 at 9:35 AM, Fabio Ceccarani <fabio.ceccar...@gmail.com> wrote: > I went around the problem: I created a page with two buttom (one for > profile) that link two differents pages. Any page has its own form and its > own controller part that write profile_type field "1" or "2". > > Thanks anyway! > Fabio > > > > > Il giorno lunedì 27 novembre 2017 12:02:08 UTC+1, Fabio Ceccarani ha > scritto: >> >> Hi Richard and thanks for answer. >> >> The real problem is how controller can know wich profile I choose in view. >> >> I want to hide profile_type field in form because I have TWO forms in >> view: one for register as PERSONAL profile, and one for register ad >> ORGANIZATION profile. >> >> But in view I have {{=form}} in any of two form. >> Is the same form=auth() but in case PERSONAL it must write "1" in >> profile_type field, and in case ORGANIZATION it must write "2" in >> profile_type field. >> >> The problem is how to pass "1" or "2" from view to controller? >> is for this reason I try to store it in session.profile_type...but last >> session.profile_type assignment ("2") in view subscribe the first ("1") >> then in controller the variable is always "2". >> >> I can't past args or vars in form submit because it is out of my control >> since it is created by auth()....or maybe yes but I did not find how to do >> it... >> >> Obviously the simplest way is show profile_type and use a single form, >> but it's most nice and easer to understand for users...and I like to >> complicate my life!! >> >> Thanks >> Fabio >> >> >> Il giorno venerdì 24 novembre 2017 16:50:17 UTC+1, Richard ha scritto: >>> >>> If you reuse the user function you can add an if statement : >>> >>> if request.args(1-2-3) or request.vars.somevarname == something >>> particular in your url depending of the context of your form: >>> db.auth_user.profile_type.default = PROFILE_TYPE_YOU_PREFER >>> elif ... >>> >>> Richard >>> >>> On Fri, Nov 24, 2017 at 10:47 AM, Richard Vézina <ml.richa...@gmail.com> >>> wrote: >>> >>>> 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 <fabio.c...@gmail.com >>>> > 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 web2py+un...@googlegroups.com. >>>>> 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 web2py+unsubscr...@googlegroups.com. > 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.