If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

Download and examples: http://labs.blouweb.com/powerformwizard

def index():
    # STEPS: A dict with fields for each step
    # title and legend will be descriptions
    mysteps = [dict(title='Personal Data',legend='Your personal info',fields=['name','lastname','birthdate']),
               dict(title='Bio', legend='Your profile bio', fields=['colors','picture','bio']),
               dict(title='Login options' , legend='Login information', fields=['email','password'])]
    # IMPORT: Import the module
    from plugin_PowerFormWizard import PowerFormWizard

    # CUSTOMIZE: Set some options
    # Client side validation
    # Show legends, hide descriptions
    options = {'description':False, 'legend':True, 'validate':True}

    # CREATE: Create the form object just like the SQLFORM - PASS the options            
    form = PowerFormWizard(db.person, steps=mysteps, options=options) 

    # VALIDATE: web2py form validation
    if form.accepts(request.vars, session):
        response.flash = "Records inserted!"
    elif form.errors: 
        form.step_validation() # VERY IMPORTANT FOR VALIDATION!!!!
        response.flash = "Errors in form"

    # Enjoy!
    return dict(form=form)


# models/db.py
colors = ['blue','red','green','yellow','pink','black']

db.define_table('person',
                Field('name'),
                Field('lastname'),
                Field('birthdate','datetime'),
                Field('colors'),
                Field('bio','text'),
                Field('picture','upload'),
                Field('email'),
                Field('password')
                )

db.person.name.requires=IS_NOT_EMPTY()
db.person.email.requires=[IS_EMAIL(), IS_NOT_EMPTY()]
db.person.colors.requires=IS_IN_SET(colors)
db.person.bio.requires = IS_LENGTH(minsize=5, maxsize=200)

Related slices

Comments (1)


Hosting graciously provided by:
Python Anywhere