I don't used the form.accepted but you could use to validate de submit the
form and handle.. but basically it's
Em sábado, 26 de novembro de 2016 20:20:58 UTC-3, Marlysson Silva escreveu:
>
> I created a other version for your code, I created a form html ( the hard
> way ) and in the controller get the post vars sent by form:
>
> The controller:
> def form():
> host_names = ["google","facebook","amazon","localhost"]
>
> marcados = request.post_vars["host"]
>
> return dict(host_names=host_names,marcados=marcados)
>
> The view:
>
> <form method="post">
> {{for host in host_names:}}
> <label for={{=host}}> {{=host}} </label>
> <input type="checkbox" name="host" value={{=host}} id={{=host}}>
> {{pass}}
> <input type="submit" name="" value="Enviar">
> </form>
>
> {{=marcados}}
>
>
> Em sábado, 26 de novembro de 2016 02:03:33 UTC-3, Jim Russell escreveu:
>>
>> Hi.
>>
>> I have created a form which takes a list of hostnames and shows the
>> hostnames with checkboxes next to it. The idea is to be able to uncheck any
>> hostnames and pass the still checked hostnames to another function which
>> will then act on that list of hostnames. The problem is that it just
>> returns an empty list.
>>
>> I am new to web2py, this is my first project, so if my thinking is wrong,
>> I'm ok with rewriting this part from scratch.
>>
>> Here is the code:
>>
>> def verify():
>> hostnames=request.vars.hostnames.split()
>> num_hosts=len(hostnames)
>> form=FORM(TABLE(TR("Hostnames")))
>> for hn in hostnames:
>> row=XML('<input type="checkbox" name="{{=hn}}" value="{{=hn}}"
>> checked>'+ hn)
>> form[0].append(row)
>> form[0].append(XML('<div id="submit"><button>Submit!</button></div>'))
>>
>> if form.accepts(request,session):
>> redirect(URL('execute',vars=dict(hostnames=form.vars.hostnames)))
>> return dict(hostnames=hostnames,form=form)
>>
>> Thanks in advance for your help.
>>
>> Jim
>>
>
--
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.