On Monday, August 29, 2022 at 3:20:22 AM UTC-7 silvia...@gmail.com wrote:

> That would be my controller function I know it is totally wrong but dont 
> know what tu put in there to be honest 
>
>
> def add():
>     form = SQLFORM(db.projects, _name='form_add')
>     
>     if country in (countryt1)
>     redirect(URL('view', vars=dict(countryt1=countryt1))  
>     return locals()
>

Well, maybe if you can mock up some screen shots showing  what you want the 
user to see, we can provide less vague advice.  
You may be wanting some extra buttons in your form besides the submit 
button.

BTW, if you're wanting the "country" variable to come from "form_add", you 
need to say something like
     if form_add.vars.country in  thesetofcountries:

If you're looking up the country in a database table, something like
    countrydata = db.countryt1[db.countryt1.countryname == 
form_add.vars.country]
  if countrydata:

See 
<URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Shortcuts>
and the paragrapsh following that.

/dps
 

>
> snide...@gmail.com schrieb am Montag, 29. August 2022 um 15:27:25 UTC+7:
>
>> On Sunday, August 28, 2022 at 7:50:27 PM UTC-7 silvia...@gmail.com wrote:
>>
>>> Actually I have 3 endpoints tier 1 tier 2 and tier 3 so example if 
>>> choosing Germany it should redirect to www.website/tier1.com if 
>>> choosing for example Viertnam it should redirect to www.website/
>>> tier3.com that is what I try to achieve but one thing is I have all my 
>>> countries in arrays sorted from tier 1 to tier 3. 
>>>
>>>
>> If those arrays are globally defined (as in db.py), then you just do 
>>        if country in tier1_array:  redirect(URL("tier1.com", ...))"
>> which is pretty much the same as Jim's suggestion.  If you need to look 
>> into the database which tier the country is in,  you probably would look 
>> that up using one of the shortcuts shown in the DAL chapter of the book.
>>
>> /dps
>>
>>  
>>
>>> Jim S schrieb am Freitag, 26. August 2022 um 19:36:30 UTC+7:
>>>
>>>> It is doing to depend on how your URLs are structured for each country 
>>>> page.  I'm guessing you'll have a different endpoint for each country in 
>>>> your set of countries.
>>>>
>>>> Likewise for Companies.  You said 'if I select company I want to 
>>>> redirect to company'.  Based on the code you posted I'm not sure what that 
>>>> means.  You don't have a 'company' field, just an entity type called 
>>>> country.  What is the endpoint that you want it to redirect to?
>>>>
>>>> -Jim
>>>>
>>>>
>>>> On Thursday, August 25, 2022 at 10:37:51 PM UTC-5 silvia...@gmail.com 
>>>> wrote:
>>>>
>>>>> Sure thanks in advance that is my DB so for example if I select 
>>>>> company I want it to redirect to company and if I select a certrain 
>>>>> country 
>>>>> lets say germany or so I want it to redirect to the german page of 
>>>>> company 
>>>>> would that be possible ?
>>>>>
>>>>> db.define_table('partner',
>>>>> Field('name'),
>>>>> Field('address'),
>>>>> Field('country',requires=IS_IN_SET(countries)),
>>>>> Field('postalcode'),
>>>>> Field('entity_type',requires=IS_IN_SET(['Company','Person'])),
>>>>> Field('partner_manager', 'reference auth_user', requires = 
>>>>> IS_IN_DB(db, 'auth_user.id','%(last_name)s')),
>>>>> Field('email'),
>>>>> Field('web'))
>>>>>
>>>>> that is my controller:
>>>>>
>>>>> def partner():
>>>>>     form = SQLFORM(db.partner, _name='form_partner')
>>>>>     if form.process().accepted:
>>>>>         session.flash = 'Partner added !'
>>>>>         redirect(URL('partnerlist'))
>>>>>     else: 
>>>>>         session.flash = 'Please try again !'
>>>>>     return dict(form=form)
>>>>> Jim S schrieb am Donnerstag, 25. August 2022 um 22:30:56 UTC+7:
>>>>>
>>>>>> Can you share the code you have so far?
>>>>>>
>>>>>> I'd probably do something like:
>>>>>>
>>>>>> form = SQLFORM.factory(...your form definition here...)
>>>>>>
>>>>>> if form.process().accepted:
>>>>>>     if form.vars.field_1 == 'some test case you want to redirect on':
>>>>>>         redirect(URL('my_redirect_url', vars=dict(my vars to pass to 
>>>>>> the redirect))
>>>>>>     elif form.vars.field_2 == 'another test case you want to redirect 
>>>>>> on':
>>>>>>         redirect(URL('my other redirect url')
>>>>>>
>>>>>> -Jim
>>>>>>
>>>>>> On Thursday, August 25, 2022 at 12:48:05 AM UTC-5 silvia...@gmail.com 
>>>>>> wrote:
>>>>>>
>>>>>>> I have a form with a few selections but I want to redirect it to a 
>>>>>>> other page depends on the selection does someone know how to do that ?
>>>>>>
>>>>>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/7b57359e-3e53-48f1-8c29-a4d52f94e6cbn%40googlegroups.com.

Reply via email to