python - Creating two separate registration forms in Web2py? -


so want create 2 registration forms side side. 1 users , other employees. index page have "click here if user" , "click here if employee". redirect appropriate registration page. want user registration how built in web2py registration is. employee registration want following fields:

  1. name 2. store name 3. store type 4. zip code

i new web2py not sure how implement this. please tell me how should go creating registration.py model this? want index redirect these 2 links appropriate:

[app]/user/register [app]/employee/register 

also controller file like? need separate controller user , employee?

your question not quite clear. want show 2 forms side side or want redirect appropriate registration page?

let's assume opt second option described in question. i'm assuming whatever reason, employees , users not same understood question.

first create employee table in models:

store_type = ['department store', 'discount store', 'warehouse store', 'mom-and-pop', 'boutique']  db.define_table('employee',                 field('first_name'),                 field('last_name'),                 field('store_name'),                 field('store_type', requires=is_in_set(store_type)),                 field('zip_code'),                 auth.signature) 

then in controller ask user if employee or user:

def index():     form = sqlform.factory(field('user_or_employee', requires = is_in_set(['user', 'employee']))).process()     if form.accepted:         if form.vars.user_or_employee == 'user':             redirect(url('user/register'))         elif form.vars.user_or_employee == 'employee':             redirect(url('employee_register'))     return locals() 

if user 'user' you'll redirect them user/register wished. if 'employee' redirect them index/employee_register

def employee_register():     form = sqlform(db.employee)     if form.process().accepted:         redirect(url('welcome')) # or whatever function wish...     return locals() 

from there can take yourself.

don't forget create views. index , default/employee-register.html. in both views should include forms you've created, that:

{{extend 'layout.html'}} <h2>please register continue</h2> {{=form}} 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -