Hi Web2py developers,

I have a trivial question, but I don't know how to solve. My index.html has 
a form with some default parameters. I get the input from users and save it 
to sessions and then redirect them to the next page with the same form 
having the input data from users. However, I don't know how to update the 
form. I tried the update() function, but doesn't seem to work. Here is my 
code:

In default.py

def index():
    form=FORM(DIV(LABEL(T("Parent Drug:"))),
              DIV(INPUT(_name="_drugsmile", _value="CCCCP")),
              DIV(LABEL(T("MS/MS Peaks:"))),
              DIV(TEXTAREA("1231 12431", _name="_peaks", _cols="20", 
_rows="5")),
              DIV(LABEL(T("Ion Mode:"))),
              DIV(DIV(INPUT(_type="radio", _name="_ionmode", _value="Positive", 
_checked="checked"), SPAN("Positive")),DIV(INPUT(_type="radio", 
_name="_ionmode", _value="Negative"), SPAN("Negative"))),
              DIV(LABEL(T("Mass Tolerance (Da):"))),
              DIV(INPUT(_name="_masstol", _value="0.04")),
              DIV(LABEL(T("Mass Error (ppm):"))),
              DIV(INPUT(_name="_masserror", _value="40")),
              DIV(INPUT(_type='submit')))
    if form.process().accepted:
        session.flash = 'form accepted'
        form.accepts(form.vars, session=session)
        session.drug_info = form.vars
        session.form = form.update() # form.update(form.vars) doesn't work, I 
am not sure why....

        redirect(URL('infodisplay'))
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill the form'
    return {"form": form}


the function I redirect to 


def infodisplay():
    # TODO
    return dict(form=session.form, druginfo=session.drug_info)



# The view

# It is a little bit of weired for my layout.html, because I want to update 
both left sidebar and main section, but I think I cannot use two {{include}} 
for here

# So, what I did is include left sidebar from default, like this


{{if left_sidebar_enabled:}}
  <div class="col-md-3 left-sidebar">
      {{block left_sidebar}}
      {{include 'default/leftbar.html'}}
      {{end}}
  </div>
{{pass}}


# for infodisplay, I have


{{extend 'layout.html'}}
{{=druginfo}}


Thanks


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

Reply via email to