SELECT(*options, name="first") ...and... SELECT(*options, name="second")
should be
SELECT(*options, _name="first") ...and... SELECT(*options, _name="second")
Anyway, args are validated and this may create problems. How about this?
def index():
options = [OPTION(texts.title, _value=texts.id) for texts in
test().select(test.slovar.ALL)]
form=FORM(TABLE(TR("Select first text",SELECT(*options, _name="first")),
TR("Select second text",SELECT(*options,
_name="second")),
TR("",INPUT(_type="submit",_value="SUBMIT"))))
if form.process().accepted:
redirect(URL('test_index1', vars = form._vars))
response.flash="form accepted"
return dict(form=form)
def test_index1():
if test.slovar(id=request.vars.first) and test.slovar(id=
request.vars.second):
text1=test(test.slovar.id==request.vars.first).select()
text2=test(test.slovar.id==request.vars.second).select()
On Friday, 18 July 2014 14:37:42 UTC-5, Maria Levchenko wrote:
>
> I'm trying to get two selected form.vars as args, but fail on it.
> There is a list of text's names, have to return two selected text.
>
> In controller:
>
> def index():
> options = [OPTION(texts.title, _value=texts.id) for texts in
> test().select(test.slovar.ALL)]
> form=FORM(TABLE(TR("Select first text",SELECT(*options, name="first")),
> TR("Select second text",SELECT(*options,
> name="second")),
> TR("",INPUT(_type="submit",_value="SUBMIT"))))
> if form.process().accepted:
> redirect(URL('test_index1', args = [form.vars['first'],
> form.vars['second']]))
> response.flash="form accepted"
> return dict(form=form)
>
> def test_index1():
> text1=test(test.slovar.id==request.args(0)).select()
> text2=test(test.slovar.id==request.args(1)).select()
>
> But index() return None and None. What I am doing wrong?
>
--
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.