Hi,

I am having trouble using the LOAD component with forms to produce a
"wizard" style multiple form type setup (eg, enter information on one
"screen", then go to the next, etc.).

If I move my mobile_verify.load file to mobile_verify.html and visit
http://localhost/myapp/default/mobile_verify/one -- the form seems to
work fine. When I keep it as a .load and it loads up in my layout, the
first form works fine, I click submit and it goes to the next form,
but the second form seems to be "stuck". When I click submit on the
second form (mobile_verify/two), it brings me back to the same form.
It appears request.vars is empty and thats why the .accepts returns
false and keeps me on that form?

In my controller I have this:
--snip--
@auth.requires_login()
def mobile_verify():
    """
    Mobile phone number verification.
    """
    # Make the user's phone number look nice
    pretty_phone = '(' + auth.user.mobile[0:3] + ') '+ \
                 auth.user.mobile[3:6] + '-' + auth.user.mobile[6:10]

    if request.args(0) == 'one':
        # Form to pick verification method
        vrfy_method_form = FORM(FIELDSET(INPUT(_type='radio',
_name='verify_method',
                                               _value='SMS'),
                                         'Send me a text (SMS)
message'),
                                FIELDSET(INPUT(_type='radio',
_name='verify_method',
                                               _value='VOICE'),
                                         'Call (voice) my mobile
phone'),
                                CENTER(INPUT(_id='text_me_button',
_type='submit',
                                             _value='Text me!'),
                                       INPUT(_id='call_me_button',
_type='submit',
                                             _value='Call me!')))

        if vrfy_method_form.accepts(request.vars, session):
            #session.flash = 'vrfy_method_form accepted'
            session.verify_method = request.vars.verify_method
            redirect(URL('mobile_verify', args='two'))

        return dict(vrfy_method_form=vrfy_method_form,
page_title='blah',
                    pretty_phone=pretty_phone)

    elif request.args(0) == 'two':
        # Form to check verification code
        chk_code_form = FORM(CENTER(FIELDSET('Type the verification
code here:',
 
INPUT(_name='verify_code',
 
requires=IS_NOT_EMPTY())),
                                    FIELDSET(INPUT(_type='submit'))))

        if chk_code_form.accepts(request.vars, session):
            #session.flash = 'chk_code_form accepted'
            session.typed_code = str(request.vars.verify_code)
            redirect(URL('mobile_verify', args='three'))

        # Verification code
        code = random.randint(100000, 999999)

        return dict(pretty_phone=pretty_phone,
chk_code_form=chk_code_form,
                    code=code, page_title='blah')

    elif request.args(0) == 'three':
        return dict(page_title='blah', pretty_phone=pretty_phone)
--snip--

For my mobile_verify.load file:
--snip--
{{if request.args(0) == 'one':}}
        <h4>How should we verify your mobile phone number?</h4>
        <center>
                My mobile phone: <strong>{{=pretty_phone}}</strong>
                <br/>
                <a href="{{=URL('user', args='profile')}}">Wrong phone 
number?</a>
        </center>
        <br/>
        {{=vrfy_method_form}}
        <script>
                jQuery(document).ready(function() {
                        jQuery('#text_me_button').hide();
                        jQuery('#call_me_button').hide();
                        jQuery('input[name="verify_method"]').change(function() 
{
                                if 
(jQuery('input[name="verify_method"]:checked').val() == 'SMS')
{
                                        jQuery('#call_me_button').hide();
                                        jQuery('#text_me_button').show();
                                } else {
                                        jQuery('#text_me_button').hide();
                                        jQuery('#call_me_button').show();
                                }
                        });
                });
        </script>
{{elif request.args(0) == 'two':}}
        {{if session.verify_method == 'SMS':}}
                {{#SendSMS(auth.user.mobile, code)}}
                An SMS text message has been sent to your mobile phone.
                {{=code}}
        {{else:}}
                {{#OriginateCall(auth.user.mobile, code)}}
                Your phone is ringing, please answer it.
                {{=code}}
        {{pass}}
        {{session.verify_code = str(code)}}
        {{=chk_code_form}}
{{elif request.args(0) == 'three':}}
        {{if session.typed_code == session.verify_code:}}
                <h4>Success!</h4>
                You should now add some contacts. Click <a 
href="{{=URL('auth_user',
args='manage_contacts')}}">here</a> to manage your contacts.
        {{else:}}
                <h4>Sorry, but the code you entered didn't work.</h4>
                Click <a href="{{=URL('auth_user', 
args='statistics')}}">here</a> to
try validating your phone again.
        {{pass}}
{{pass}}
--snip--

For the view that calls the LOAD function:
{{extend 'layout.html'}}
<div id="box3" class="box-style">
        <h2 class="title">{{=page_title}}</h2>
        <div class="content">
                {{if auth.user.phone_verified == False:}}
                        {{=LOAD(c='default', f='mobile_verify', args='one',
extension='load', ajax=True)}}
                {{else:}}
                        <p>blah</p>
                {{pass}}
        </div>
</div>
--snip--

Help! Any ideas are greatly appreciated.

Version 1.91.6 (2011-01-03 17:55:14)


--Marc

Reply via email to