Maybe the issue is due to class 'active' in the view.
To be honest, I did not fully understand your question but the following 
code - for example - should show the tab with the submitted form.

*controllers/default.py*
def report():
    query = (db.table_0.id > 0)

    #redirect_url_0 = 'report_detail'
    formname_0 = 'formname_0'

    form_0 = SQLFORM.factory(
        Field("from_date", "date", 
              requires = IS_DATE() ),
        Field("to_date", "date", 
              requires = IS_DATE() ), 
        Field("table_0", "list:reference table_0", 
              requires = IS_EMPTY_OR(IS_IN_DB(db(query), db.table_0.id, 
                                              db.table_0._format, multiple 
= True) ) )
        )
    if form_0.process(formname = formname_0).accepted:
        #response.new_window = URL(redirect_url_0, vars = form_0.vars)
        redirect_url_0 = URL('report', vars = dict(tab_active="tab-1"))
        redirect(redirect_url_0)
    elif form_0.errors:
        response.flash = T('Form has errors')

    #redirect_url_1 = 'report_summary'
    formname_1 = 'formname_1'

    form_1 = SQLFORM.factory(
        Field("from_date", "date", 
              requires = IS_DATE() ),
        Field("to_date", "date", 
              requires = IS_DATE() ), 
        Field("table_0", "list:reference table_0", 
              requires = IS_EMPTY_OR(IS_IN_DB(db(query), db.table_0.id, 
                                              db.table_0._format, multiple 
= True) ) )
        )
    if form_1.process(formname = formname_1).accepted:
        #response.new_window = URL(redirect_url_1, vars = form_1.vars)
        redirect_url_1 = URL('report', vars = dict(tab_active="tab-2"))
        redirect(redirect_url_1)
    elif form_1.errors:
        response.flash = T('Form has errors')

    return dict(form_0 = form_0, form_1 = form_1)

*views/default/report.html*
{{extend 'layout.html'}}

<ul class="nav nav-tabs">
  <li class={{="active" if request.vars['tab_active']!= 'tab-2' else ""}}>
  <a data-toggle="tab" href="#tab-1">Detail</a>
  </li>
  <li class={{="active" if request.vars['tab_active'] == 'tab-2' else ""}}>
  <a data-toggle="tab" href="#tab-2">Summary</a>
  </li>
</ul>

<div class="tab-content">
  <div id="tab-1" class="tab-pane fade in {{="active" if 
request.vars['tab_active'] != 'tab-2' else ""}}">
    {{=BR() }}
    {{=form_0}}
  </div>

  <div id="tab-2" class="tab-pane fade in {{="active" if 
request.vars['tab_active'] == 'tab-2' else ""}}">
    {{=BR() }}
    {{=form_1}}
  </div>
</div>



Il giorno sabato 12 agosto 2017 03:54:45 UTC+2, 黄祥 ha scritto:
>
> is it possible to have multiple form in 1 page using tab? z
> tried it before but no luck (no error occured but the result is not 
> expected) the result that should open the new browser tab didnt open, after 
> submit it just return flash 'success'
> *e.g.*
> *controllers/default.py*
> def report():
> query = (db.table_0.id > 0)
>
> redirect_url_0 = 'report_detail'
> formname_0 = 'formname_0'
>
> form_0 = SQLFORM.factory(
> Field("from_date", "date", 
>  requires = IS_DATE() ),
> Field("to_date", "date", 
>  requires = IS_DATE() ), 
> Field("table_0", "list:reference table_0", 
>  requires = IS_EMPTY_OR(IS_IN_DB(db(query), db.table_0.id, 
>    db.table_0._format, multiple = True) ) )
> )
> if form_0.process(formname = formname_0).accepted:
> response.new_window = URL(redirect_url_0, vars = form_0.vars)
> #redirect(URL(redirect_url, vars = form.vars) )
> elif form_0.errors:
> response.flash = T('Form has errors')
>
> redirect_url_1 = 'report_summary'
> formname_1 = 'formname_1'
>
> form_1 = SQLFORM.factory(
> Field("from_date", "date", 
>  requires = IS_DATE() ),
> Field("to_date", "date", 
>  requires = IS_DATE() ), 
> Field("table_0", "list:reference table_0", 
>  requires = IS_EMPTY_OR(IS_IN_DB(db(query), db.table_0.id, 
>    db.table_0._format, multiple = True) ) )
> )
> if form_1.process(formname = formname_1).accepted:
> response.new_window = URL(redirect_url_1, vars = form_1.vars)
> #redirect(URL(redirect_url, vars = form.vars) )
> elif form_1.errors:
> response.flash = T('Form has errors')
>
> return dict(form_0 = form_0, form_1 = form_1)
>
> *views/default/report.html*
> {{extend 'layout.html'}}
>
> <ul class="nav nav-tabs">
>   <li class="active">
>   <a data-toggle="tab" href="#tab-1">Detail</a>
>   </li>
>   <li>
>   <a data-toggle="tab" href="#tab-2">Summary</a>
>   </li>
> </ul>
>
> <div class="tab-content">
>   <div id="tab-1" class="tab-pane fade in active">
>     {{=BR() }}
>     {{=form_0}}
>   </div>
>
>   <div id="tab-2" class="tab-pane fade">
>     {{=BR() }}
>     {{=form_1}}
>   </div>
> </div>
>
> thanks and best regards,
> stifan
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to