What is the final answer of default/second.html in Documentation (Postbacks/Internationalization)?

26 views
Skip to first unread message

terencenwk

unread,
Sep 7, 2014, 5:49:08 AM9/7/14
to web...@googlegroups.com
Regarding to Postbacks in Documentation:

(1) What is the final answer of default/second.html if the the default controller finally changed to:
def first():
    form = SQLFORM.factory(Field('visitor_name', requires=IS_NOT_EMPTY()))
    if form.process().accepted:
        name = form.vars.visitor_name
        redirect(URL('second',vars=dict(name=name)))
    return dict(form=form)

def second():
    name = request.vars.name or redirect(URL('first'))
    return dict(name=name)
(2) How to use T Operator in above example?  Because there is an error if I add:
label='what is your name?'
in above example.

Massimo Di Pierro

unread,
Sep 7, 2014, 11:37:32 AM9/7/14
to web...@googlegroups.com
This should work fine:

form = SQLFORM.factory(Field('visitor_name', requires=IS_NOT_EMPTY(), label=T('what is your name?')))

terencenwk

unread,
Sep 7, 2014, 10:09:03 PM9/7/14
to web...@googlegroups.com
In Views: default/second.html, is this correct?

{{extend 'layout.html'}}
<h1>Hello {{=name or "anonymous"}}</h1>
Reply all
Reply to author
Forward
0 new messages